Skip to content

[BUG] Move semantics not working as expected #214

@general-rishkin

Description

@general-rishkin

Describe the bug
Use of moved value after move.

To Reproduce
This should fail but does not:

struct Mover {
  val: int
}

fn consume(m: Mover) {
  println "m.val = {m.val}"
}

fn main() {
  let m = Mover { val: 10 }
  consume(m) // m moved
  
  // Use after move (Call - Negative Test)
  consume(m); // Should fail: Use of moved value 'm'
}

Expected behavior
Second call to ```consume`` should fail.

Screenshots

     Running a.out
m.val = 10
m.val = 10

Environment (please complete the following information):

  • OS: Ubuntu 25.10
  • Zen C Version: v0.4.0-108-g26bc7ce
  • Compiler: GCC 15

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions