Odin icon indicating copy to clipboard operation
Odin copied to clipboard

`using` sometimes doesn't work

Open alexover1 opened this issue 9 months ago • 7 comments

Context

For some reason, occasionally the using statement or parameter attribute does not import members correctly.

Odin:    dev-2024-05-nightly:2250eb3e7
OS:      Ubuntu 22.04.4 LTS, Linux 6.5.0-28-generic
CPU:     12th Gen Intel(R) Core(TM) i7-1260P
RAM:     15692 MiB
Backend: LLVM 17.0.6

Expected Behavior

Entity :: struct {
    using position: Vector2,
    type: typeid,

    submerged: bool,

    // Entity manager state:

    manager: ^Entity_Manager,
    
    slot_index: int,
}

Human :: struct {
    using entity: Entity,

    dead: bool,
    active: bool,
}

move_human :: proc (using human: ^Human, delta: Vector2) -> bool {
    push: [dynamic] ^Entity
    
    next_position := position + delta
    
    if solid := find_solid(manager, next_position); solid != nil {
        append(&push, solid)
        for {
            if manager.walls[next_position] {
                return false
            }
            
            solid := find_solid(manager, next_position)
            if solid != nil {
                append(&push, solid)
                next_position += delta
            } else {
                break
            }
        }
    }

    return true
}

Current Behavior

The members of the Human struct cannot be found in the scope of the procedure.

Failure Information (for bugs)

/home/alex/sokoban/player.odin(8:22) Undeclared name: position 
	next_position := position + delta 
	                 ^~~~~~~^ 
/home/alex/sokoban/player.odin(10:28) Undeclared name: manager 
	if solid := find_solid(manager, next_position); solid != nil { 
	                       ^~~~~~^ 
/home/alex/sokoban/player.odin(13:16) Undeclared name: manager 
	if manager.walls[next_position] { 
	   ^~~~~~^ 
/home/alex/sokoban/player.odin(17:33) Undeclared name: manager 
	solid := find_solid(manager, next_position) 
	                    ^~~~~~^ 

alexover1 avatar May 13 '24 19:05 alexover1