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] Debugging when using Optional[String](None) shows a JIT error #2657

Open
osawyerr opened this issue May 14, 2024 · 1 comment
Open
Labels
bug Something isn't working Initiative: Debugger mojo-repo Tag all issues with this label

Comments

@osawyerr
Copy link

osawyerr commented May 14, 2024

Bug description

Running the program below in debug mode throws shows a JIT error

Steps to reproduce

Run the code below in VSCode in debug mode

fn main() :
    var val1 = 2
    var val2 = Optional[String](None)
 
    print("foo", "bar", "baz") # set breakpoint here
error: JIT(0x300000000)(0x0000000300000000) The parsed MLIR structure type '!kgen.variant, struct<(struct<(pointer, index, index) memoryOnly>) memoryOnly>>' has not byte size. The MLIR type won't be used and regular MLIR-agnostic DWARF parsing will be performed.
error: JIT(0x300000000)(0x0000000300000000) [MojoDWARFParser::ParseTypeFromDWARF]: Unhandled type tag. Die = 0x3c0, tag = DW_TAG_variant_part, name = DW_TAG_variant_part
error: JIT(0x300000000)(0x0000000300000000) [MojoDWARFParser::CompleteTypeFromDWARF]: Couldn't complete the struct type '!kgen.variant, struct<(struct<(pointer, index, index) memoryOnly>) memoryOnly>>' because one of its fields has no size. Die = 0x3a6, member die = 0x3ad.
error: JIT(0x300000000)(0x0000000300000000) [MojoDWARFParser::CompleteTypeFromDWARF]: The struct type 'pkg stdlib::pkg utils::module variant::struct Variant[`variadic>`]<`:variadic> [[@"stdlib::collections::optional::_NoneType" : anystruct<@"stdlib::collections::optional::_NoneType">, {"__copyinit__" : (!lit.ref<@"stdlib::collections::optional::_NoneType", mut *[0,0]> init_self, !lit.ref<@"stdlib::collections::optional::_NoneType", imm *[0,1]> borrow_in_mem) -> !kgen.none = @"stdlib::collections::optional::_NoneType::__copyinit__(stdlib::collections::optional::_NoneType=&,stdlib::collections::optional::_NoneType)", "__del__" : (!lit.ref<@"stdlib::collections::optional::_NoneType", mut *[0,0]> owned_in_mem) -> !kgen.none = @"stdlib::collections::optional::_NoneType::__del__(stdlib::collections::optional::_NoneType)", "__moveinit__" : (!lit.ref<@"stdlib::collections::optional::_NoneType", mut *[0,0]> init_self, !lit.ref<@"stdlib::collections::optional::_NoneType", mut *[0,1]> owned_in_mem) -> !kgen.none = @"stdlib::collections::optional::_NoneType::__moveinit__(stdlib::collections::optional::_NoneType=&,stdlib::collections::optional::_NoneType)"}], [@"stdlib::builtin::string::String" : anystruct<@"stdlib::builtin::string::String">, {"__copyinit__" : (!lit.ref<@"stdlib::builtin::string::String", mut *[0,0]> init_self, !lit.ref<@"stdlib::builtin::string::String", imm *[0,1]> borrow_in_mem) -> !kgen.none = @"stdlib::builtin::string::String::__copyinit__(stdlib::builtin::string::String=&,stdlib::builtin::string::String)", "__del__" : (!lit.ref<@"stdlib::builtin::string::String", mut *[0,0]> owned_in_mem) -> !kgen.none = @"stdlib::builtin::string::String::__del__(stdlib::builtin::string::String)", "__moveinit__" : (!lit.ref<@"stdlib::builtin::string::String", mut *[0,0]> init_self, !lit.ref<@"stdlib::builtin::string::String", mut *[0,1]> owned_in_mem) -> !kgen.none = @"stdlib::builtin::string::String::__moveinit__(stdlib::builtin::string::String=&,stdlib::builtin::string::String)"}]]`>' doesn't have the same size as reported in the DWARF after type completion. Die = 0x253c.
error: JIT(0x300000000)(0x0000000300000000) [MojoDWARFParser::CompleteTypeFromDWARF]: The struct type 'pkg stdlib::pkg collections::module optional::struct Optional[`trait<@stdlib::@builtin::@value::@CollectionElement>`]<`:trait<@"stdlib::builtin::value::CollectionElement"> [@"stdlib::builtin::string::String" : anystruct<@"stdlib::builtin::string::String">, {"__copyinit__" : (!lit.ref<@"stdlib::builtin::string::String", mut *[0,0]> init_self, !lit.ref<@"stdlib::builtin::string::String", imm *[0,1]> borrow_in_mem) -> !kgen.none = @"stdlib::builtin::string::String::__copyinit__(stdlib::builtin::string::String=&,stdlib::builtin::string::String)", "__del__" : (!lit.ref<@"stdlib::builtin::string::String", mut *[0,0]> owned_in_mem) -> !kgen.none = @"stdlib::builtin::string::String::__del__(stdlib::builtin::string::String)", "__moveinit__" : (!lit.ref<@"stdlib::builtin::string::String", mut *[0,0]> init_self, !lit.ref<@"stdlib::builtin::string::String", mut *[0,1]> owned_in_mem) -> !kgen.none = @"stdlib::builtin::string::String::__moveinit__(stdlib::builtin::string::String=&,stdlib::builtin::string::String)"}]`>' doesn't have the same size as reported in the DWARF after type completion. Die = 0x2529.
foo bar baz

System information

- What OS did you do install Mojo on ? = MacOS Apple Silicon M3
- Provide version information for Mojo by pasting the output of `mojo -v` = mojo 24.3.0 (9882e19d)
- Provide Modular CLI version by pasting the output of `modular -v` = modular 0.8.0 (39a426b5)
@osawyerr osawyerr added bug Something isn't working mojo-repo Tag all issues with this label labels May 14, 2024
@walter-erquinigo
Copy link
Contributor

Thanks for reporting this! I'll revisit our handling of optional and variant types and fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Initiative: Debugger mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants