Odin
Odin copied to clipboard
`using` variable struct whose member variable is the same as a parameter produces no compile error
Context
Currently, if you use the following code:
package main
import "core:fmt"
Foo :: struct {
A : int,
}
Something :: struct {
A : int,
}
main :: proc () {
execute(20);
}
execute :: proc (A : int) {
something := Something{};
using something;
A = A;
fmt.println(something.A);
}
Does not produce a compile error, instead, runs fine and generates the image found under section below.
- Operating System & Odin Version: Windows 10 Pro, odin version dev-2022-01-nightly:65434911
- Please paste
odin reportoutput:
Odin: dev-2022-01-nightly:65434911 OS: Windows 10 Professional (version: 21H1), build 19043.1415 CPU: 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz RAM: 32635 MiB
Expected Behavior
Apparently, shadowing parameters is legal but can lead to some unexpected behaviour when used in conjunction with a using statement for a variable holding a member variable of the same name as that parameter.
In this instance, the compiler should at least produce a warning to suggest two variables of the same name are being used in the scope and context where the using statement is being used.
Current Behavior
By compiling and debugging the above code, the following results are seen:

Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- Copy & Paste the above code into a small file
- Compile and debug
Hello!
I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue
- open a PR referencing and resolving the issue;
- leave a comment on it and discuss ideas how you could contribute towards resolving it;
- leave a comment and describe in detail why this issue is critical for your use case;
- open a new issue with updated details and a plan on resolving the issue.
The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..