You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: Expected AddressKeyword or AsciiStringLiteral or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DeleteKeyword or DoKeyword or FalseKeyword or FixedBytesType or ForKeyword or FunctionKeyword or HexLiteral or HexStringLiteral or Identifier or IfKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SignedFixedType or SignedIntegerType or StringKeyword or ThrowKeyword or TrueKeyword or UnsignedFixedType or UnsignedIntegerType or VarKeyword or WhileKeyword.
We can add a flag (e.g. error_recovery = (override_children_expectations: bool)) to StructItem and EnumItem and other non-terminal items .. When any item fails to parse its children, and only when the error position has made no progress in input stream, we replace the current "expectations list" of children kinds with the current parent kind only, propagating it up the stack. This leads to nicer errors like:
Error: Expected Expression or Statement.
Error: Expected Modifier or FunctionAttribute.
Open Questions
Should this behaviour be enabled by default, and only disabled where needed? which is the better DX here?
Do we even need a flag here? can we enable this for all enums for now? does this miss anything?
The text was updated successfully, but these errors were encountered:
Instead of something like this:
Error: Expected AddressKeyword or AsciiStringLiteral or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or CloseBrace or ContinueKeyword or DecimalLiteral or DeleteKeyword or DoKeyword or FalseKeyword or FixedBytesType or ForKeyword or FunctionKeyword or HexLiteral or HexStringLiteral or Identifier or IfKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SignedFixedType or SignedIntegerType or StringKeyword or ThrowKeyword or TrueKeyword or UnsignedFixedType or UnsignedIntegerType or VarKeyword or WhileKeyword.
We can add a flag (e.g.
error_recovery = (override_children_expectations: bool)
) toStructItem
andEnumItem
and other non-terminal items .. When any item fails to parse its children, and only when the error position has made no progress in input stream, we replace the current "expectations list" of children kinds with the current parent kind only, propagating it up the stack. This leads to nicer errors like:Error: Expected Expression or Statement
.Error: Expected Modifier or FunctionAttribute
.Open Questions
The text was updated successfully, but these errors were encountered: