-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Description
Type mismatch while setting the value for the default argument generates wrong code but no compilation error.
func foo[T](arr: openArray[T], idx: Natural = arr.high): int = # missed conversion: `Natural(arr.high)`
if idx == 0:
return 0
foo(arr, idx - 1)
let arr = [0, 1, 2]
assert foo(arr) == 0
Nim Version
Nim Compiler Version 1.9.3 [Windows: amd64]
Compiled at 2023-06-15
Current Output
error: 'arr_p0Len_0' undeclared (first use in this function)
203 | if (((arr_p0Len_0-1)) < ((NI)0) || ((arr_p0Len_0-1)) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI((arr_p0Len_0-1), ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;
| ^~~~~~~~~~~
C:...\@mtest.nim.c:203:23: note: each undeclared identifier is reported only once for each function it appears in
Error: execution of an external compiler program 'gcc.exe -c -w -fmax-errors=3 -mno-ms-bitfields -IC:...\lib -Iy:\ -o C:\...\@mtest.nim.c.o C:\...\@mtest.nim.c' failed with exit code: 1