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

Unclear error message when an immutable object is being lifted to inflight #6566

Open
staycoolcall911 opened this issue May 26, 2024 · 1 comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler

Comments

@staycoolcall911
Copy link
Contributor

I tried this:

let a = MutArray<num> [1,2];
a.push(3); //succeeds because a is mutable

test "mutability disabled on inflight error message should be improved" { // test syntax currently implies inflight, so referenced preflight expressions are lifted by the compiler 
  a.push(4); //fails because during lifting a was implicitly converted to immutable
}

This happened:

Compiler error within the test block:

error: Member "push" doesn't exist in "Array"
  --> wing/main.w:5:5
  |
5 |   a.push(4);
  |     ^^^^

I expected this:

In #6258 we added the compiler behavior to convert mutable preflight expressions to immutable when lifting them to inflight.
So, I was expecting calling a.push() inflight to fail, but it is unclear from the error message that a is not mutable anymore or what should I do.

I would expect an error message in the spirit of:
Preflight "MutArray" object was implicitly converted to "Array" when lifting to inflight - for additional information please see https://www.winglang.io/docs/concepts/inflights#using-preflight-data-from-inflight

Important to note that if I would use a non existing method name (e.g. a.pushhhh()), I would still expect to get the current error message: error: Member "pushhhh" doesn't exist in "Array".

Is there a workaround?

No response

Anything else?

No response

Wing Version

0.74.14

Node.js Version

No response

Platform(s)

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@staycoolcall911 staycoolcall911 added 🐛 bug Something isn't working 🛠️ compiler Compiler labels May 26, 2024
Copy link

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@github-actions github-actions bot added the Stale label Aug 25, 2024
@Chriscbr Chriscbr removed the Stale label Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

2 participants