-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
"IndexDefect" error in compiler/guards.nim(72) isLetLocation #16202
Comments
@jiyinyiyong can you please minimize into a reproducible minimum example? it'll not only help fix this (although the fix seems simple here) but also help with adding a regression test.
type Foo = object
f0: ref string
proc main()=
var f = Foo()
if f.f0[] == "bar":
echo "ok1"
echo "ok2"
static: main()
main() gives a bad error (no stacktrace) in VM:
|
@timotheecour tried just now but failed. most similar example I got, but still can't reproduce the error: import os
type A = ref string
type AK = enum
kOfA,
lOfA,
type Cr = object
case kind: AK
of kOfA:
kVal: A
of lOfA:
lVal: string
let a = new A
a[] = "demo"
let cr = Cr(kind: kOfA, kVal: a)
let xs: seq[Cr] = @[cr]
proc showError(message: string) =
raise newException(ValueError, message)
let cr2 = xs[0]
if cr2.kind == kOfA:
if cr2.kVal[] != "false": # <-- corresponding to this line
showError("wrong value")
else:
echo "ok"
else:
showError("not the kind") I also tried to print logs as I did to find out At first I guessed if requireNode.kind == crDataKeyword:
if requireNode.keywordVal[] != "require":
raiseEvalError("Expects :require", requireNode) so do you have any ideas what https://github.com/nim-lang/Nim/blob/devel/compiler/guards.nim#L72 is doing? |
this is why we really need dustmite-like tool, refs #8276
|
logs:
it's
tried |
I think the issue is also produceable by cloning parent commit of calcit-lang/calcit-runner.nim@52d0c40 if more thorough analysis is wanted. |
Original post on forum https://forum.nim-lang.org/t/7181 .
Current Output
Ran into an error in my own project,
it was very strange since it happened when I added
import os
in one of my files, whileimport os
is totally valid code.Possible Solution
As described in post, I managed to bypass the exception by changing calcit-lang/calcit-runner.nim@52d0c40 , refactored
to
Additional Information
with help from @xflywind I managed to grab some logs from Nim compiler and located suspicious code
.keywordVal[]
.. and My guess is the compiler treated my codekeywordVal[]
as seq accessing, while it's actually dereferencing.https://github.com/nim-lang/Nim/blob/devel/compiler/guards.nim#L72
It happens occasionally. I don't know why adding
import os
triggers this error.CI running logs can be found at https://github.com/Cirru/calcit-runner.nim/runs/1478046706 .
The text was updated successfully, but these errors were encountered: