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

Map.get() does not play well with Map of optional types #4525

Closed
hasanaburayyan opened this issue Oct 12, 2023 · 1 comment
Closed

Map.get() does not play well with Map of optional types #4525

hasanaburayyan opened this issue Oct 12, 2023 · 1 comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler

Comments

@hasanaburayyan
Copy link
Contributor

I tried this:

let m = MutMap<str?>{ };
m.set("a", nil);
let b = m.get("a");

assert(b == nil);

This happened:

ERROR: Map does not contain key: "a"

test/target/app.main.wsim.537045.tmp/.wing/preflight.js:9
       super(scope, id);
       const m = ({"a": "azz"});
>>     const b = ((obj, key) => { if (obj["key"] === undefined) throw new Error(`Map does not contain key: "${key}"`); return obj["key"]; })(m, "a");
     }
   }

I expected this:

b == nil

Is there a workaround?

No response

Component

Compiler

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Anything else?

Perhaps we might be able to change the output js to null instead of undefined?

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.
@hasanaburayyan hasanaburayyan added the 🐛 bug Something isn't working label Oct 12, 2023
@hasanaburayyan hasanaburayyan changed the title Map.get() does not work well with Map of optional types Map.get() does not play well with Map of optional types Oct 12, 2023
@hasanaburayyan
Copy link
Contributor Author

closing as this is fixed #4523 (comment)

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
None yet
Development

No branches or pull requests

1 participant