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]: Parser crash from importing nonexistant module and using with statement #1558

Closed
isuckatcs opened this issue Dec 24, 2023 · 0 comments
Labels
bug Something isn't working crash mojo Issues that are related to mojo mojo-lang Tag for all issues related to language. mojo-repo Tag all issues with this label

Comments

@isuckatcs
Copy link
Contributor

Bug description

from collections.foo import bar


fn main() raises:
    with open("/dev/stdin", "r") as stdin:
        pass
error: unable to locate module 'foo'
from collections.foo import bar
     ^
@"$collections"::@"$vector"::@DynamicVector
mojo: /__w/modular/modular/KGEN/lib/MojoParser/DeclResolver.cpp:679: M::KGEN::LIT::ASTDecl &M::KGEN::LIT::DeclResolver::getDeclForTypeSymbol(mlir::SymbolRefAttr) const: Assertion `it != declForTypeSymbol.end() && "Unknown decl symbol!"' failed.
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 repro.mojo
1.      Crash resolving decl body at loc(".../repro.mojo":4:1)
    >> fn main() raises:
       ^................
    >>     with open("/dev/stdin", "r") as stdin:
       .........................................<
2.      Crash parsing statement at loc(".../repro.mojo":5:5)
    >>     with open("/dev/stdin", "r") as stdin:
           ^....................................<

If the with statement is not present, the crash does not occur.

from collections.foo import bar


fn main() raises:
    # with open("/dev/stdin", "r") as stdin:
    pass
error: unable to locate module 'foo'
from collections.foo import bar
     ^
mojo: error: failed to parse the provided Mojo

Steps to reproduce

  • run the snippet in the description with mojo

System information

- Ubuntu 22.04.3 LTS (WSL 2)
- mojo 0.6.1 (876ded2e)
- modular 0.3.1 (589ce200)
@isuckatcs isuckatcs added bug Something isn't working mojo Issues that are related to mojo labels Dec 24, 2023
@ematejska ematejska added the mojo-lang Tag for all issues related to language. label Jan 3, 2024
@Mogball Mogball closed this as completed Feb 23, 2024
@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 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 crash mojo Issues that are related to mojo mojo-lang Tag for all issues related to language. mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants