Open
Description
Currently if
is implemented in the body visitor, but the global level if
statement seems to be translated in the symbol table visitor:
def main0():
print("OK!")
if __name__ == "__main__":
main0()
The error is:
$ lpython a.py
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
File "/Users/ondrej/repos/lpython/src/bin/lpython.cpp", line 880
err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir, compiler_options, time_report);
File "/Users/ondrej/repos/lpython/src/bin/lpython.cpp", line 354
r1 = LFortran::LPython::python_ast_to_asr(al, *ast, diagnostics, true,
File "/Users/ondrej/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 3630
auto res = symbol_table_visitor(al, *ast_m, diagnostics, main_module,
File "/Users/ondrej/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 2251
v.visit_Module(ast);
File "/Users/ondrej/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 1994
visit_stmt(*x.m_body[i]);
File "/Users/ondrej/repos/lpython/src/lpython/python_ast.h", line 1862
void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
File "/Users/ondrej/repos/lpython/src/lpython/python_ast.h", line 1741
case stmtType::While: { v.visit_While((const While_t &)x); return; }
File "/Users/ondrej/repos/lpython/src/lpython/python_ast.h", line 1874
void visit_If(const If_t & /* x */) { throw LFortran::LFortranException("visit_If() not implemented"); }
LFortranException: visit_If() not implemented
We might be able to leave these to be parsed in the body visitor somehow, or we need to move these into the symbol table visitor.
(The __name__
function works already, so that's not an issue.)
Metadata
Metadata
Assignees
Labels
No labels