wing icon indicating copy to clipboard operation
wing copied to clipboard

improve error message when accessing an optional map property

Open tsuf239 opened this issue 2 years ago • 6 comments

Feature Spec

Assuming we have an optional Map, and we want to access one of its properties, optional_map.get("property") (or even optional_map?.get("property")) will throw the following error: "property access unsupported on type Map?" this error message might not be clear enough to guide the user on how to fix the error.

(At the end I solved it this way:

let m = optional_map ?? {property: "x"};
m.get("property");

)

Use Cases

accessing a property on an optional map

Implementation Notes

We will also support optional_map?.property in the future

Component

Language Design

Community Note

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.

tsuf239 avatar Apr 09 '23 14:04 tsuf239

optional_map?.get("property") should actually work - it is just not implemented yet - see #436

staycoolcall911 avatar Apr 11 '23 14:04 staycoolcall911

Hi,

This issue hasn't seen activity in 60 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[bot] avatar Jun 11 '23 06:06 github-actions[bot]

Hi,

This issue hasn't seen activity in 60 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[bot] avatar Aug 14 '23 06:08 github-actions[bot]

An example for this error message:

let m: Map<str>? = {"a" => "aaa"};
log(m?.get("a"));

Yields the following compile time error message:

error: Expected type to be "str", but got "str?" instead

The error message should direct the user to unwrap the optional value (by using if let or the ?? operator).

staycoolcall911 avatar Aug 14 '23 07:08 staycoolcall911

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[bot] avatar Apr 24 '24 06:04 github-actions[bot]

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[bot] avatar Aug 03 '24 06:08 github-actions[bot]