asoffer / Icarus

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

Implicit array -> slice cast is broken #95

Closed asoffer closed 2 years ago

asoffer commented 2 years ago

Reproducer:

a := [true, true, true]
s: []bool = a
// What is s.length?

A workaround is to explicitly construct the slice, in this case, slice(&a[0], a:?.length)

perimosocordiae commented 2 years ago

Reopening this one because your recent commit introduced a related issue:

foo := [-1, -1]

results in the following error:

[140536296625992 ir/builder.cc:214 ApplyImplicitCasts] Unreachable code-path.
([2; integer], casting implicitly to, []([2; i64]))
*** SIGABRT received at time=1640831202 on cpu 0 ***
PC: @     0x7fd12813c808  (unknown)  pthread_kill
    @          0x18fd5f0         64  absl::WriteFailureInfo()
    @          0x18fd2d4        224  absl::AbslFailureSignalHandler()
    @     0x7fd1280e8520  (unknown)  (unknown)
Aborted (core dumped)
perimosocordiae commented 2 years ago

And if you try to provide an array type:

foo: [2; i64] = [-1, -1]

it yields the error: No viable cast from `[2; integer]` to `[2; i64]`.