odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.6k stars 576 forks source link

Assertion Failure: `type == t_string` #1911

Closed jembishop closed 5 months ago

jembishop commented 2 years ago

Context

Odin: dev-2022-07-nightly:4af8a645
 OS:   Ubuntu 20.04 LTS, Linux 5.4.0-109-generic
 CPU:  Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz
 RAM:  96486 MiB

Expected Behavior

Tried to compile this.

package main

import "core:fmt"
import "core:slice"

main :: proc() {

    a := []string{"hello", "boris"};
    words_c:= slice.clone(a)

    for w, idx in words_c {
        fmt.println(w[:3])
    }
}

Should compile and running should print

hel
bor

Current Behavior

Compiling gives

src/llvm_backend_expr.cpp(4010): Assertion Failure: `type == t_string` 
[1]    459870 illegal hardware instruction (core dumped)

However if I add in the type explicitly it works, ie

package main

import "core:fmt"
import "core:slice"

main :: proc() {

    a := []string{"hello", "boris"};
    words_c:[]string = slice.clone(a) // add type explicitly here

    for w, idx in words_c {
        fmt.println(w[:3])
    }
}

works as expected.

rick-masters commented 5 months ago

This was fixed by https://github.com/odin-lang/Odin/pull/3037 and can be closed.