File tree Expand file tree Collapse file tree 3 files changed +74
-6
lines changed Expand file tree Collapse file tree 3 files changed +74
-6
lines changed Original file line number Diff line number Diff line change @@ -454,10 +454,10 @@ exports.Lexer = class Lexer
454
454
indent = match[0 ]
455
455
456
456
prev = @ prev ()
457
- backslash = prev? and prev [0 ] is ' \\ '
457
+ backslash = prev? [0 ] is ' \\ '
458
458
@seenFor = no unless backslash and @seenFor
459
- @seenImport = no unless @importSpecifierList
460
- @seenExport = no unless @exportSpecifierList
459
+ @seenImport = no unless (backslash and @seenImport ) or @importSpecifierList
460
+ @seenExport = no unless (backslash and @seenExport ) or @exportSpecifierList
461
461
462
462
size = indent .length - 1 - indent .lastIndexOf ' \n '
463
463
noNewlines = @ unfinished ()
Original file line number Diff line number Diff line change @@ -853,3 +853,70 @@ test "#4491: import- and export-specific lexing should stop after import/export
853
853
854
854
from('foo');
855
855
"""
856
+
857
+ # Issue #4874: Backslash not supported in import or export statements
858
+ test " #4874: backslash `import`" , ->
859
+
860
+ eqJS """
861
+ import foo \
862
+ from 'lib'
863
+
864
+ foo a
865
+ """ ,
866
+ """
867
+ import foo from 'lib';
868
+
869
+ foo(a);
870
+ """
871
+
872
+ eqJS """
873
+ import \
874
+ foo \
875
+ from \
876
+ 'lib'
877
+
878
+ foo a
879
+ """ ,
880
+ """
881
+ import foo from 'lib';
882
+
883
+ foo(a);
884
+ """
885
+
886
+ eqJS """
887
+ import \
888
+ utilityBelt \
889
+ , {
890
+ each
891
+ } from \
892
+ 'underscore'
893
+ """ ,
894
+ """
895
+ import utilityBelt, {
896
+ each
897
+ } from 'underscore';
898
+ """
899
+
900
+ test " #4874: backslash `export`" , ->
901
+ eqJS """
902
+ export \
903
+ * \
904
+ from \
905
+ 'underscore'
906
+ """ ,
907
+ """
908
+ export * from 'underscore';
909
+ """
910
+
911
+ eqJS """
912
+ export \
913
+ { max, min } \
914
+ from \
915
+ 'underscore'
916
+ """ ,
917
+ """
918
+ export {
919
+ max,
920
+ min
921
+ } from 'underscore';
922
+ """
You can’t perform that action at this time.
0 commit comments