Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Compiler crashes on an array of values with different types, which has "using"

Open greenya opened this issue 7 months ago • 0 comments

Context

odin report output:

    Odin:    dev-2024-07-nightly:fc2e31f
    OS:      Windows 11 Home Basic (version: 23H2), build 22631.3880
    CPU:     AMD Ryzen 7 5700X 8-Core Processor
    RAM:     32688 MiB
    Backend: LLVM 18.1.8

Expected Behavior

Compiler should not crash. This code has error which should be reported by the compiler. Basically, it seems it forgets to check allowed types of items provided for array initialization; maybe this has something to do with "using", because as soon as I remove it, compiler see each struct as separate type and correctly tells error. My view is: image

Current Behavior

Compiler ends with Segmentation fault error code image

Also tested on macOS (it prints an assertion failed check) image

Failure Information (for bugs)

Steps to Reproduce

The following code reproduces the issue:

package main

import "core:fmt"

Tile :: struct {
    name: string,
}

TileGround :: struct {
    using tile: Tile,
    some_ground_prop: int,
}

TileTree :: struct {
    using tile: Tile,
    some_tree_prop: int,
}

main :: proc() {
    tiles := []Tile {
        Tile {},
        TileGround { name="green grass", some_ground_prop=7 },
        TileTree { name="tall tree", some_tree_prop=9 },
    }

    fmt.println(tiles)
}

greenya avatar Jul 24 '24 00:07 greenya