DSLX: Ambiguous parse leads to bad error message
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
Consider:
```
import common
fn foo () {
let A = common::MyStruct {
a: u32:0,
b: undefined_t:1,
};
}
```
Currently, in Parser::ParseTerm, we'll first try to evaluate `common::MyStruct { ... }` as a StructInstance. If that fails, we fall back to just returning the ColonRef of `common::MyStruct` (in the case that it'd be part of a condtional, as in `if a > common::MY_CONST { ... }`).
Unfortunately, here, the StructInstance interpretation is correct, so its error message should be returned ("Cannot find a definition for name: 'undefined_t'). It's hard, though, to know what to do inside ParseTerm (whether to return an error or fall back to a ColonRef).
Should we look ahead to see if the next tokens are and , as one would do for defining a struct's members? Should we add extra checking to ParseTernaryExpression in case parsing of "test" fails (to then try a StructDefinition)? I can't take the time to look at this right now, but I'm sure it'll bite us again...so let's fix it soon :)
Contributor guide
Assessment
This issue has not been assessed yet.