"Silent" error when using variable before it's definition
LensPlaysGames opened this issue · 5 comments
LensPlaysGames commented
I'm not sure what's going wrong here, but when using a variable as if it's been defined, even though it hasn't, there are no user-facing errors other than a return code of 2...
foo : integer(state : integer) {
idx := 0
while idx < colcount {
;;putchar(
;; if state & (1 << idx) {
;; 42
;; } else {
;; 32
;; }
;;)
if state & (1 << idx) {
putchar(42)
} else {
putchar(32)
}
idx := idx + 1
}
putchar(10)
}
idx : integer = 0
foo(1)
NOTE: No output file is ever written. It looks like we are exiting from https://github.com/LensPlaysGames/FUNCompiler/blob/17c4d1bc8f45f093b10638423044ebd0748b5256/src/main.c#L304 silently, which is very not ideal.
LensPlaysGames commented
Sirraide commented
I think variable lookup may be a bit broken atm...
LensPlaysGames commented
Example at examples/vec2.int
is also suffering from the same problem.
vec2 :> type {
x : integer
y : integer
}
vec2_add : vec2(a : vec2, b : vec2) {
out : vec2
out.x := a.x + b.x
out.y := a.y + b.y
out
}
a : vec2
a.x := 34
b : vec2
b.a := 420
b.x := 35
vec2_add(a, b).y
LensPlaysGames commented
Fixed!