AzureMarker / intellij-lalrpop

Jetbrains plugin for the LALRPOP parser-generator
MIT License
16 stars 2 forks source link

Support fallible actions #28

Closed Schyrsivochter closed 3 years ago

Schyrsivochter commented 3 years ago

Currently, when using fallible actions, the plugin erroneously treats the action code as if returning the nonterminal’s return type directly, rather than a Result. This leads to perfectly valid code being marked as ‘mismatched types’.

Adjust the Rust code injection so that action code of a rule marked with =>? rather than => returns not T, but Result<T, Error> where Error is the grammar’s user error type, which is &'static str by default but can be overriden (extern { type Error = ... })

Schyrsivochter commented 3 years ago

hold on, I’m stupid. this was already implemented in #24 the other day

dnbln commented 3 years ago

which is &'static str by default

Wait I got this bit wrong, and assumed it was () :grimacing:

AzureMarker commented 3 years ago

It looks like the default changed in 0.14 from () to &'static str: https://github.com/lalrpop/lalrpop/blob/6fd067fb4a14243b2dc396c6d4487958460e01e4/RELEASES.md#version-014

dnbln commented 3 years ago

It's sad the book isn't kept up to date. I used the last snippet in http://lalrpop.github.io/lalrpop/tutorial/002_paren_numbers.html to get the defaults.