asoffer / Icarus

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

Type verification misses invalid in-place assignment of array element #91

Closed perimosocordiae closed 2 years ago

perimosocordiae commented 2 years ago

It's easier to demo this one than describe it:

foo: [4; i64]
idx: i64 = 2

idx += true
foo[idx] = true
foo[idx] += true

Error messages:

Error in repro.ic:
No matching binary operator (+=) for types `i64` and `bool`.

  4 | idx += true

Error in repro.ic:
Cannot assign a value of type `bool` to a reference of type `i64`:

  5 | foo[idx] = true

[139691635808072 ./ast/node.xmacro.h:24 Visit] Unreachable code-path.
(Index)
*** SIGABRT received at time=1638554040 on cpu 1 ***
PC: @     0x7f0c7e5e8808  (unknown)  pthread_kill
    @          0x1933800         64  absl::WriteFailureInfo()
    @          0x19334e4        224  absl::AbslFailureSignalHandler()
    @     0x7f0c7e594520  (unknown)  (unknown)
Aborted (core dumped)

The first two diagnostics are working as intended, no problems there. The last one (for foo[idx] += true) should presumably result in a similar diagnostic as the first one.