-
-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Prior to commit b24ce4d the following code was valid:
struct Test
{
a: String;
b: int;
}
fn main() -> int {
let x = String::from("Hello"); // heap
let test: Test = Test{ a: x, b: 1 }; // stack
x.forget();
test.a.free();
return 0;
}At+after that commit the following error is emitted:
error: Use of moved value 'x'
--> code.zc:16:5
|
16 | x.forget();
| ^ here
|
= help: This type owns resources and cannot be implicitly copied
|
= help: Consider using a reference ('&') to borrow the value instead
To Reproduce
Checkout the commit prior to b24ce4d
-
git checkout 68525fd9fbbef05bd116505312d2d3ef5574960d -
make clean && make install -
zc run code.zc
= works
Checkout the commit after 68525fd
git checkout b24ce4d7849cec02a9f336f2c1264e0d907bf0c9
or git checkout main
-
make clean && make install -
zc run code.zc
= error
Expected behavior
It should work (unless I'm mistaken) since forget() is intended to make test.a the owner of x.
Screenshots
n/a
Environment (please complete the following information):
- OS: Ubuntu 22.04.1
- Zen C Version: latest
- Compiler: GCC 13.3.0
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Backlog