Fix #4491: import- and export-specific lexing should stop#4492
Merged
GeoffreyBooth merged 3 commits intojashkenas:masterfrom Apr 9, 2017
Merged
Conversation
GeoffreyBooth
requested changes
Apr 8, 2017
| @seenImport = no # Used to recognize IMPORT FROM? AS? tokens. | ||
| @seenExport = no # Used to recognize EXPORT FROM? AS? tokens. | ||
| @exportSpecifierList = no # Used to identify when in an EXPORT {...} FROM? ... | ||
| @importSpecifierList = no # Used to identify when in an IMPORT {...} FROM? ... |
Collaborator
There was a problem hiding this comment.
Please keep it consistent and always put the import stuff before the export stuff.
src/lexer.coffee
Outdated
| @exportSpecifierList = yes | ||
| else if @exportSpecifierList and value is '}' | ||
| @exportSpecifierList = no | ||
| else if value is '{' and @seenImport |
Collaborator
Author
|
@GeoffreyBooth ok put imports first Also updated previously merged (via #4490) fix for #4489 to follow style guide and use camelCase |
Collaborator
|
Thanks. Looks good to me, @lydell? |
GeoffreyBooth
approved these changes
Apr 8, 2017
vendethiel
reviewed
Apr 8, 2017
| if value is '{' and prev?[0] is 'EXPORT' | ||
| if value is '{' and @seenImport | ||
| @importSpecifierList = yes | ||
| else if @importSpecifierList and value is '}' |
Collaborator
There was a problem hiding this comment.
this doesn't handle nested objects, right?
Collaborator
Author
There was a problem hiding this comment.
@vendethiel right, I didn't see any cases in the documentation or tests where an import could contain nested-object syntax?
Collaborator
There was a problem hiding this comment.
@vendethiel the “destructuring” in ES2015 import statements is just a similar-looking syntax:
import { a: b } from 'lib'repl: ES2015 named imports do not destructure. Use another statement for destructuring after the import. (1:12)
> 1 | import { a: b } from 'lib'
| ^
This was referenced Apr 9, 2017
Merged
EsrefDurna
pushed a commit
to EsrefDurna/coffeescript
that referenced
this pull request
Nov 12, 2025
…ashkenas#4492) * Fix jashkenas#4491: import- and export-specific lexing should stop * split up tests * fixes from code review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4491 (I think)
I'm not really familiar with the
import/exportsyntax but it looks like the only the time that the import-/export-specific lexing controlled by@seenImport/@seenExport(which lexesas,from,defaultdifferently) needs to continue beyond a line break is if we're inside a{...}specifier list. So I added an@importSpecifierList(corresponding to the existing@exportSpecifierList), and unless one of these is set (indicating we're inside a specifier list) then seeing alineToken()clears@seenImportand@seenExportNot sure if I should add additional tests for any of the other various
import/exportsyntaxes?