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

ast, parser: implement simple AST poisoning #9525

Merged
merged 21 commits into from
Mar 30, 2021

Conversation

nedpals
Copy link
Member

@nedpals nedpals commented Mar 30, 2021

This PR implements a feature similar to #7236 but in a minimal, non-destructive way:

  • Error node is NodeError (See: [0])
  • Does not replace ast.File's errors but only references them with an array index where the error is located.
  • Only used in parser methods that return an empty ast.Stmt{} or ast.Expr{} element.

This feature is crucial in order to eliminate most of the crashes VLS is experiencing on every change due to an invalid memory error on the nodes that were identified as unknown ast.Stmt / unknown ast.Expr.
image

Notes

[0] - NodeError is used due to some conflict when using Error as the struct name when including it into a sumtype (I suspect it's a naming conflict with the builtin Error)

<v folder>/vlib/v/ast/ast.v:1437:16: error: type `Error` has no field or method `pos`
 1435 |         SelectorExpr, SizeOf, SqlExpr, StringInterLiteral, StringLiteral, StructInit, Type, TypeOf,
 1436 |         UnsafeExpr {
 1437 |             return expr.pos
      |                         ~~~
 1438 |         }
 1439 |         IfGuardExpr {

@medvednikov medvednikov merged commit b319068 into vlang:master Mar 30, 2021
@nedpals nedpals deleted the simple-ast-poisoning branch March 30, 2021 07:38
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 this pull request may close these issues.

3 participants