yeti
yeti copied to clipboard
typo in record passes compile
I wrote this program, making a typo:
typedef tree<a> = Leaf a | Node {left is tree , right is tree };
t1 is tree<number> = Node { left=Leaf 1,right=Node { left=Leaf 10, right=Leaf 2 }};
t2 is tree<number> = Node { left=Leaf 1,right=Node{ left=Leaf 2,rigt=Leaf 3 }};
println t1;
println t2;
walk t is tree<'a> -> list<'a> = (
case t of
Leaf v : [v];
Node {left,right} : (walk left) ++ (walk right);
esac;
);
println(walk t1);
println(walk t2);
in t2 the last node is rigt
not right
. Compile passes and program fails with:
Node {left=Leaf 1, right=Node {left=Leaf 10, right=Leaf 2}}
Node {left=Leaf 1, right=Node {left=Leaf 2, rigt=Leaf 3}}
[1,10,2]
java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
at yeti.lang.Struct3.get(Struct3.java:50)
at x$walk.apply(x.yeti)
at x$walk.apply(x.yeti:17)
at x.main(x.yeti:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at yeti.lang.compiler.eval._1(eval.yeti:102)
at yeti.lang.compiler.eval.execClass(eval.yeti:76)
at yeti.lang.compiler.eval$compileYetiFiles$.apply(eval.yeti:354)
at yeti.lang.compiler.yeti._3(yeti.yeti:231)
at yeti.lang.compiler.yeti.main(yeti.yeti:224)
Am I doing something wrong or is it a bug ?
Using yeti 1.0
At first sight, a bug. Nothing that compiles should get such exception at runtime without using unsafely_as. I'll look into it. Probably will do 1.1 release when I find a fix, embedded asm library upgrade is anyway needed for JDK 18+ support.