ark-lang / ark

A compiled systems programming language written in Go using the LLVM framework
https://ark-lang.github.io/
MIT License
677 stars 47 forks source link

Mutability doesn't seem to compile in some cases #691

Closed felixangell closed 8 years ago

felixangell commented 8 years ago

Take the example here, we have a variable that is made mutable, though the compiler moans:

error: [file:30:2] Cannot assign value to immutable access
    f.path = path;
    ^

error: [file:31:2] Cannot assign value to immutable access
    f.handle = C::fopen(f.path.location); 

Though in the context of the function that code is in, the path that we assign is mutable, as is the f variable.

kiljacken commented 8 years ago

You have an immutable pointer and thus cannot assign the field on the struct. But as luck would have it you can cast an immutable pointer to a mutable one because yolo

felixangell commented 8 years ago

Bless :heart: