Skip to content

Comments can mess with the resulting ast's semantics #133

Open
@julian-berbel

Description

@julian-berbel

The following code:

function foo() {
  return
  bar()
}

is properly parsed to the following output:

Right (JSAstProgram [JSFunction 'foo' () (JSBlock [JSReturn ,JSMethodCall (JSIdentifier 'bar',JSArguments ())])])

However, this semantically identical piece of code:

function foo() {
  return //
  bar()
}

Seems to get parsed to the following:

Right (JSAstProgram [JSFunction 'foo' () (JSBlock [JSReturn JSMemberExpression (JSIdentifier 'bar',JSArguments ()) ])])

Here, the parser is interpreting the code as the function returning the result of bar(), instead of them being separate sentences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions