Open nzhang opened 2 months ago
Might be related to #3099.
# Zn: @value is a little confusing as it doe not mean immutable class. # Zn: how to define a immutable struct in Mojo?
@value
means "make it a value type", there is nothing about mutability. Also, there is no way to make an immutable structure in Mojo currently.
Thank you for the quick response @soraros , particularly answering my own questions while still learning the language :)
@value
decorator.
Bug description
I tried to run the following example program with (intended) wrong ownership annotation of one of the parameter. It output the correct error message but followed by a crash. I then realized that I didn't have LLVM installed on my mac. After installing LLVM (and llvm-symbolizer) the crash went away. So it is possible that the crash is caused by the fact that llvm-symbolizer is not found.
Steps to reproduce
Include relevant code snippet or link to code that did not work as expected. =================== The source code: ===================
fn pets(): var a = MyPet("Loki", 4) var b = MyPet("Sylvie", 2) print(a.name)
Zn: @value is a little confusing as it doe not mean immutable class.
fn main(): pets()
(base) nings-mbp:del ningzhang$ '/Users/ningzhang/.modular/pkg/packages.modular.com_max/bin/mojo' '/Users/ningzhang/test/mojo_max/del/del.mojo' /Users/ningzhang/test/mojo_max/del/del.mojo:15:33: error: existing value argument must be passed as owned fn moveinit(inout self, rhs: MyPet): ^ Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes. Stack dump:
System information