modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
22.75k stars 2.57k forks source link

[BUG][Regression] Struct definition with recursive reference (no longer gives an error message and) crashes #2208

Open siitron opened 4 months ago

siitron commented 4 months ago

Bug description

I believe the issue https://github.com/modularml/mojo/issues/74 has resurfaced.

The following code will segfault:

#crash.mojo
@value
struct Node:
    var rec: Node

But I expected the error message:

$🍔  mojo crash.mojo 
crash.mojo:3:5: error: recursive nested struct field, try adding indirection to recursive reference
    var rec: Node
    ^
crash.mojo:2:1: error: struct contains recursive reference to itself
struct Node:
^

Steps to reproduce

System information

- OS: Debian (WSL)
- Mojo version: mojo 2024.4.117 (8f6529b0)
- Modular CLI version: modular 0.6.0 (04c05243)

(Please tag with regression label.)

ematejska commented 4 months ago

@Mogball Heads up looks like a regression.

siitron commented 3 months ago

Update: Currently with mojo 2024.5.2605 (9c328b12), I get two identical warnings followed by Segmentation fault. The warning message is "warning: self recursive call will cause an infinite loop".