astexplorer icon indicating copy to clipboard operation
astexplorer copied to clipboard

Display flow-parser errors like other parsers

Open jedwards1211 opened this issue 7 years ago • 1 comments

Describe the bug Right now the flow-parser appears to accept anything and spit out a bogus AST for bogus input. But what's really happening is the Program node it generates also has an errors property containing the parse errors.

At some point I'll try to make a PR to fix this.

To Reproduce Steps to reproduce the behavior:

  1. Select flow parser
  2. Enter code type switch = number
  3. See output screenshot

Expected behavior Something like babel does, "Unexpected token, expected ";" (1:5)" and line 1 highlighted in red

We should probably just make the flow parser wrapper check the errors property and throw something if there are errors. @fkling does AST explorer have infrastructure for displaying multiple error messages at once? If not we could just throw the first error.

And, is it possible to highlight errors in red but also still display the questionable AST output on the right?

Screenshots image

Browser (please complete the following information): irrelevant, happens on any browser

astexplorer settings:

  • Selected parser: [e.g. flow]
  • code: type switch = number

Additional context This had been confusing me for awhile, I mistakenly thought that flow-parser was stupidly permissive until I noticed the errors property on the output AST

jedwards1211 avatar Dec 14 '18 20:12 jedwards1211

Sounds like a good idea!

fkling avatar Dec 18 '18 04:12 fkling