Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export statement followed by expression #77

Closed
Fee0 opened this issue Nov 25, 2022 · 5 comments · Fixed by #78
Closed

Export statement followed by expression #77

Fee0 opened this issue Nov 25, 2022 · 5 comments · Fixed by #78

Comments

@Fee0
Copy link

Fee0 commented Nov 25, 2022

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?

@FreeMasen
Copy link
Collaborator

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();
}

@Fee0
Copy link
Author

Fee0 commented Nov 28, 2022

Wouldn't we get two semicolons now when we write this out?

@FreeMasen
Copy link
Collaborator

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.

@Fee0
Copy link
Author

Fee0 commented Nov 28, 2022

Ah makes sense. Good job :)

@FreeMasen
Copy link
Collaborator

This was merged as part of 0.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants