Open junweizeng opened 6 months ago
mojo crashes on the following code (i.e. test.mojo).
@value struct a: def __copyinit__(inout b, c: Self):
$ mojo build test.mojo /path/to/test.mojo:3:5: error: cannot define '__copyinit__' as 'def'; 'def' implicitly raises def __copyinit__(inout b, c: Self): ^~~ fn /path/to/test.mojo:2:1: error: duplicate definition of '__copyinit__' struct a: ^ 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: 0. Program arguments: mojo build test.mojo 1. Crash resolving decl body at loc("/path/to/test.mojo":2:1) >> struct a: ^........ >> def __copyinit__(inout b, c: Self): .......................................< #0 0x0000560f46e4ce47 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x62ae47) #1 0x0000560f46e4aa1e (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x628a1e) #2 0x0000560f46e4d51f (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x62b51f) #3 0x00007f254fe5c520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #4 0x0000560f47252cd8 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa30cd8) #5 0x0000560f472e3a83 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xac1a83) #6 0x0000560f47273b5c (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa51b5c) #7 0x0000560f47285563 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa63563) #8 0x0000560f47270f99 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa4ef99) #9 0x0000560f4727448c (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa5248c) #10 0x0000560f4728892a (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa6692a) #11 0x0000560f47288fc8 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa66fc8) #12 0x0000560f47236cfb (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa14cfb) #13 0x0000560f47237059 (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0xa15059) #14 0x0000560f46df5e0f (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5d3e0f) #15 0x0000560f46df823b (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5d623b) #16 0x0000560f46df2ddf (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5d0ddf) #17 0x0000560f46df165d (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5cf65d) #18 0x00007f254fe43d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #19 0x00007f254fe43e40 call_init ./csu/../csu/libc-start.c:128:20 #20 0x00007f254fe43e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #21 0x0000560f46df0fae (/home/jwzeng/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x5cefae)
- Ubuntu 22.04 LTS - mojo 24.1.0 (55ec12d6) - modular 0.5.1 (1b608e3d)
Here's a similar code that reproduces the crash:
@value struct a: fn __moveinit__(inout b, c: Self):
Another one:
@value struct a: fn __copyinit__(inout b, c: Self): fn __copyinit__
Bug description
mojo crashes on the following code (i.e. test.mojo).
Steps to reproduce
System information