Compiler accepts &int as a key for map[int]int #23069
Labels
Bug
This tag is applied to issues which reports bugs.
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Unit: Type System
Bugs/feature requests, that are related to the V types system.
Describe the bug
Compiler accepts &int as a key for map[int]int instead of pointing out to the developer type difference. This leads to unexpected behavior, because pointer is also a number.
Reproduction Steps
It will print something like
{-925552672: 1}
which is probably something unexpected by developer.Expected Behavior
Error from compiler pointing out that I passed
&int
type, but map expectsint
.Additional +10 to stats for suggesting that you can deref it with
*
f.i.:did you mean m[*ptr] ?
Current Behavior
Compiler accepts pointer and does not show any warning/error.
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.8 e8e6c76
Environment details (OS name and version, etc.)
The text was updated successfully, but these errors were encountered: