Export statement followed by expression
Fee0 opened this issue · 5 comments
Following code results in an error. But only when written in one line.
export let a; a=1;
Works like this:
export let a;
a=1;
It seems function parse_export_decl
tries to consume a semicolon twice. Once inside parse_lexical_decl
and once inside the function itself. Instead of semicolon it also accepts newline.
Can we simply remove the consume_semicolon
call inside parse_export_decl
?
Is the semicolon preferred to be in the inner or outer expression?
Since we are re-using the parse_lexical_decl
for non-exports, I believe the semi-colon we should be using is the one on Decl::Var
. We should probably have both the Decl::Export
and the Decl::Var
semicolon carry to the same Slice
so that would mean we can replace the call in parse_export_decl
with
if let Decl::Var { semi_colon, .. } = &lex {
semi = semi_colon.clone();
}
Wouldn't we get two semicolons now when we write this out?
That is a good observation! In the PR I have up currently (#78) I move the semicolon to the outer decl instead of cloning it.
Ah makes sense. Good job :)
This was merged as part of 0.8.1