asoffer / Icarus

An experimental general-purpose programming language
Apache License 2.0
9 stars 2 forks source link

Slice lengths are broken #114

Open perimosocordiae opened 2 years ago

perimosocordiae commented 2 years ago
--   ::= import "core.ic"
io   ::= import "io.ic"

foo := "abc"
io.Print(foo.length, "\n")

bar := builtin.slice(foo.data, 2)
io.Print(bar.length, "\n")

Output:

3
32062544

I'm not sure if this is an issue with the SliceLengthInstruction or the builtin.slice() function, or something else entirely.

asoffer commented 2 years ago

Replacing the numeric literal 2 with n and declaring n: u64 = 2 above works around the issue, but n :: u64 = 2 or n ::= 2 do not. Also explicitly passing 2 as u64 works. This makes me think it's something happening with the implicit cast from integer to u64.