-
Notifications
You must be signed in to change notification settings - Fork 38
Conversation
src/res_core.ml
Outdated
@@ -5411,7 +5411,7 @@ and parseJsImport ~startPos ~attrs p = | |||
let decl = | |||
match parseJsFfiDeclaration p with | |||
| Some decl -> decl | |||
| None -> assert false | |||
| None -> JsFfi.emptyDecl p.startPos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See how other errors are handled.
E.g. just a few lines above here:
Parser.err ~startPos:attrLoc.loc_start ~endPos:attrLoc.loc_end p
(Diagnostics.message (ErrorMessages.attributeWithoutNode attr));
Currently it goes all the way to the end of the file silently (e.g. in the provided test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see this example for where to define the default value to use (inside Recover
:
Parser.err p (Diagnostics.unexpected token p.breadcrumbs);
Recover.defaultModuleExpr ()
@cristianoc Please check what I added for error handling. |
FWIW |
@IwanKaramazow Thank you for informing of what was going on. |
Let's remove it. |
I guess it means starting over with this PR |
Then, should I close this PR? 🤔 |
Or just undo the changes. Don't think anything will stay. |
The idea is to literally remove parsing "import". |
The same goes for "export". |
Here's what it would look like: #597 after removing all the resulting dead code reported from the analysis which runs on The same goes for |
Assertion in
parseJsImport
function can fail, so I guess it should be properly treated instead of assertion.import@
The problem is,
parseJsFfiDeclaration
happens to returnNone
which violates assertion.I patched it by handling
None
case with an empty declaration, but I'm not sure it is a right way.