Skip to content

Python file read twice ? #2475

Open
Open
@rebcabin

Description

@rebcabin

repro:

lldb lpython -- --show-asr tests/expr8.py

first time it's read is line 128 of lpython.cpp

    frame #0: 0x000000010000e794 lpython`(anonymous namespace)::emit_asr(infile="tests/expr8.py", pass_manager=0x000000016fdfe7d8, runtime_library_dir="/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/bin/../runtime", with_intrinsic_modules=false, compiler_options=0x000000016fdfe870) at lpython.cpp:200:5
   197 	        std::string input = LCompilers::read_file(infile);
   198 	        lm.init_simple(input);
   199 	        lm.file_ends.push_back(input.size());
-> 200 	    }
   201 	    LCompilers::Result<LCompilers::LPython::AST::ast_t*> r1 = parse_python_file(
   202 	        al, runtime_library_dir, infile, diagnostics, 0, compiler_options.new_parser);
   203 	    std::cerr << diagnostics.render(lm, compiler_options);

second time it's read is line 125 of parser.cpp

    frame #0: 0x00000001000c9f78 lpython`LCompilers::LPython::parse_python_file(al=0x000000016fdfd2b0, (null)="/Users/brian/Dropbox/Mac/Documents/GitHub/lpython/src/bin/../runtime", infile="tests/expr8.py", diagnostics=0x000000016fdfd298, prev_loc=0, new_parser=true) at parser.cpp:126:49
   123 	    new_parser = true;
   124 	    LCOMPILERS_ASSERT(new_parser)
   125 	    std::string input = read_file(infile);
-> 126 	    Result<LPython::AST::Module_t*> res = parse(al, input, prev_loc, diagnostics);
   127 	    if (res.ok) {
   128 	        ast = (LPython::AST::ast_t*)res.result;
   129 	    } else {

intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ParserIssues or improvements related to parserenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions