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
When the parser encounters a language item that is not enabled/reserved in the current language version, it currently doesn't attempt to parse it, and eventually entering error recovery:
EnumVariants
Optional Fields
PrimaryExpression
Keyword
Possibly others?
For example, for Optional Fields that are not legal in the current version, instead of skipping, we can still attempt parsing it, and if successful, produce the complete tree, along with an error about versioning. It is a very common case of errors for end users, and a core goal of the DSL v2 to enable:
We can still produce complete valid trees, with no missing/skipped nodes.
Instead of a long list of tokens: Expected Foo or Bar or Baz, we will produce meaningful/actionable errors: Foo is not valid in the current language version 'XXX'. It requires language version 'YYY' or above.
I suspect EnumVariants and Optional Fields have the biggest impact. We can experiment/start with that. That means instead of this:
ifself.version_is_at_least_XXXX{let result = self.parse_foo_bar(input);
helper.consider(input, result)?;}
With the errors API we will have by #804, we can switch this bit around:
let result = self.parse_foo_bar(input);if !self.version_is_at_least_XXXX{
result.add_diagnostic(DiagnosticKind::VersionTooLow(XXXX));}
helper.consider(input, result)?;
Open Questions
Can this later enable other features like Error recovery grammar nodes #128? We can add a reason: String field to VersionSpecifier::Never, and use it to "manually guide" error recovery. For example, adding an EventDefinition under SourceUnitMember with VersionSpecifier::Never(reason = "Events are only valid inside contracts").
The text was updated successfully, but these errors were encountered:
When the parser encounters a language item that is not
enabled
/reserved
in the current language version, it currently doesn't attempt to parse it, and eventually entering error recovery:EnumVariant
sField
sPrimaryExpression
Keyword
For example, for Optional
Field
s that are not legal in the current version, instead of skipping, we can still attempt parsing it, and if successful, produce the complete tree, along with an error about versioning. It is a very common case of errors for end users, and a core goal of the DSL v2 to enable:Expected Foo or Bar or Baz
, we will produce meaningful/actionable errors:Foo is not valid in the current language version 'XXX'. It requires language version 'YYY' or above
.I suspect
EnumVariant
s and OptionalField
s have the biggest impact. We can experiment/start with that. That means instead of this:With the errors API we will have by #804, we can switch this bit around:
Open Questions
reason: String
field toVersionSpecifier::Never
, and use it to "manually guide" error recovery. For example, adding anEventDefinition
underSourceUnitMember
withVersionSpecifier::Never(reason = "Events are only valid inside contracts")
.The text was updated successfully, but these errors were encountered: