Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Compiler crash with (indirect) self referential type #3322

Open
lsh opened this issue Jul 27, 2024 · 0 comments
Open

[BUG] Compiler crash with (indirect) self referential type #3322

lsh opened this issue Jul 27, 2024 · 0 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@lsh
Copy link
Contributor

lsh commented Jul 27, 2024

Bug description

If there is a self referential type, where the value is behind a pointer such that it should be valid, it still causes a compiler crash.

Steps to reproduce

struct Val:
    alias _Storage = Variant[
        String,
        Dict[String, Val],
    ]
    var _value: Self._Storage

    fn isa[T: CollectionElement](self) -> Bool:
        return self._value.isa[T]()

    fn __init__(inout self, string: String):
        self._value = string

    fn __init__(inout self, dict: Dict[String, Val]):
        self._value = dict

    fn __moveinit__(inout self, owned rhs: Self):
        self._value = rhs._value

    fn __copyinit__(inout self, rhs: Self):
        self._value = rhs._value


fn main():
    print(Val(str("a")).isa[String]())

outputs

 #0 0x000000010427ed58 llvm_strlcpy (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1000bed58)
 #1 0x000000010427d12c llvm_strlcpy (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1000bd12c)
 #2 0x000000010427f3f8 llvm_strlcpy (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1000bf3f8)
 #3 0x000000018393b584 (/usr/lib/system/libsystem_platform.dylib+0x180477584)
 #4 0x00000001054e0d7c mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x101320d7c)
 #5 0x00000001054e1158 mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x101321158)
 #6 0x000000010580714c mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x10164714c)
 #7 0x0000000183834548 (/usr/lib/libc++.1.dylib+0x180370548)
 #8 0x00000001058ac8e0 mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1016ec8e0)
 #9 0x00000001058b2034 mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1016f2034)
#10 0x00000001058b1d70 mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1016f1d70)
#11 0x00000001058b1e0c mbedtls_version_get_number (/Users/lukas/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo+0x1016f1e0c)
#12 0x000000018390af94 (/usr/lib/system/libsystem_pthread.dylib+0x180446f94)
#13 0x0000000183905d34 (/usr/lib/system/libsystem_pthread.dylib+0x180441d34)

System information

- What OS did you do install Mojo on ? MacOS
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 2024.7.2705 (4b7a0ee2)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.7.2 (d0adc668)
@lsh lsh added bug Something isn't working mojo-repo Tag all issues with this label labels Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

1 participant