Skip to content

js: objects are always references #222

@serkonda7

Description

@serkonda7

Description and Reproduction Sample

struct Foo {
    mut x i32
}

fun main() {
	mut a := Foo{}
	b := a
	a.x = 3
	println(a)
	println(b)
}

Current Behavior

JS backend:

Foo{
  x = 3
}
Foo{
  x = 3
}

C backend:

Foo{
  x = 3
}
Foo{
  x = 0
}

Expected Behavior

JS should behave like C

Possible Solution and Additional Information

No response

Environment details (bait doctor)

Version: Bait 0.0.7 81a5a9a
OS: linux/x64
Git: git version 2.47.0
Node.js: v23.1.0
CC: cc (GCC) 14.2.1 20240910

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions