-
Notifications
You must be signed in to change notification settings - Fork 256
Disallow duplicate names between types and functions #169
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
Changes from all commits
a2760a6
48f7e62
4a26d00
ee8aec9
be59b14
4badedd
22b8a8a
63d1225
0cba638
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,6 @@ package-lock.json | |
| node_modules | ||
| ace | ||
| *.wasm | ||
| .vscode | ||
| wasi-sdk-* | ||
| **/*/.mypy_cache | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| "foo" defined twice | ||
| Function "foo" already defined as a Function | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be better to use "function" instead of "Function" here personally (avoiding the capital "F")
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be better to use "function" instead of "Function" here personally (avoiding the capital "F") |
||
| --> tests/ui/parse-fail/duplicate-functions.wit:4:1 | ||
| | | ||
| 4 | foo: func() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // parse-fail | ||
|
|
||
| type foo = s32 | ||
| foo: func() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Function "foo" already defined as a Type | ||
| --> tests/ui/parse-fail/func-type-collide.wit:4:1 | ||
| | | ||
| 4 | foo: func() | ||
| | ^-- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| a: s32 | ||
| b: tuple<> | ||
| record a {} | ||
| c: tuple<u32, a> | ||
| record c {} | ||
| d: tuple<u32, c> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation-wise I think that this isn't the best way to structure this one-namespace limitation. To support multiple namespaces the resolution here uses separate hash maps to prevent collisions between maps, for example
resource_lookupandtype_lookup. I think that instead of having a duplicate map here track that it would be better to have something likename_lookupwhich matches to anenumlike this. That waydefine_{resource,type}and function insertion below would all modify the map.