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

unsupported operator: <Test::Msg>.bar_ instead of unknown field #1790

Closed
awelzel opened this issue Jul 11, 2024 · 2 comments · Fixed by #1889 or #1892
Closed

unsupported operator: <Test::Msg>.bar_ instead of unknown field #1790

awelzel opened this issue Jul 11, 2024 · 2 comments · Fixed by #1889 or #1892

Comments

@awelzel
Copy link
Contributor

awelzel commented Jul 11, 2024

Very minor, but "unsupported operator" for a typo'ed field doesn't seem quite appropriate.

$ cat msg.spicy 
module Test;

type Msg = unit {
  var x: uint16;
  bar: uint16;

  on %done {
    self.x = self.bar_;
  }
};
$ spicyc -j  msg.spicy -o msg.hlto
[error] msg.spicy:8:14-8:22: unsupported operator: <Test::Msg>.bar_
[error] spicyc: aborting after errors
$ spicyc --version
spicyc v1.11.0-dev.251 (6581b185)
@bbannier
Copy link
Member

bbannier commented Jul 11, 2024

Flagging this as regression since in v1.10 (prior to #1462) we used to report for this snippet

[error] msg.spicy:8:18: type does not have field 'bar_'

@rsmmr
Copy link
Member

rsmmr commented Aug 6, 2024

I think this needs a special-casing: if an AST ends up with anexpression::UnresolvedOperator node, check if its Kind::Member and if so, see if the reason why it couldn't be resolved is because there's no such field in the type; then report it as such instead of the generic error message. We already do similar special-casing for Kind::MemberCall to show candidate functions.

@rsmmr rsmmr added the Good first issue Good for newcomers label Aug 6, 2024
@rsmmr rsmmr self-assigned this Oct 15, 2024
@bbannier bbannier linked a pull request Oct 16, 2024 that will close this issue
@rsmmr rsmmr closed this as completed in e529e9b Oct 17, 2024
rsmmr added a commit that referenced this issue Oct 17, 2024
* origin/topic/robin/gh-1790-unknown-field:
  Prioritize error message reporting unknown field.
  Provide proper error message when trying access an unknown unit field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants