Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Request print support for dictionaries; and should not throw LCompilersException #1971

Open
@rebcabin

Description

@rebcabin

Two issues: (1) `LPython should produce an error message and not a traceback (see bottom):

(2) Dict print is really useful for print debugging, e.g.,

def lexer_test():
    print('LEXER TEST')
    lexer : LasrLexer = LasrLexer(StringIO('  foo  bar  '))
    eat_white(lexer)
    t : str = peek(lexer)
    print({"t": t})  ############# ATTENTION ##############
    assert t == 'f'

produces today:

/Users/brian/CLionProjects/lpython/src/bin/python /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/lasr_lexer.py 
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  File "/Users/brian/CLionProjects/lpython/src/bin/lpython.cpp", line 1844
    err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
  File "/Users/brian/CLionProjects/lpython/src/bin/lpython.cpp", line 809
    res = fe.get_llvm3(*asr, pass_manager, diagnostics, infile);
  File "/Users/brian/CLionProjects/lpython/src/lpython/python_evaluator.cpp", line 58
    run_fn, infile);
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 8518
    v.visit_asr((ASR::asr_t&)asr);
  File "../libasr/asr.h", line 4869
  File "../libasr/asr.h", line 4845
  File "../libasr/asr.h", line 4870
  File "../libasr/asr.h", line 4585
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 1359
    ASR::symbol_t *mod = x.m_global_scope->get_symbol(item);
  File "../libasr/asr.h", line 4872
  File "../libasr/asr.h", line 4593
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 2925
    finish_module_init_function_prototype(x);
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 4321
    visit_Function(*s);
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 3926
    visit_procedures(x);
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 4272
    this->visit_stmt(*x.m_body[i]);
  File "../libasr/asr.h", line 4889
  File "../libasr/asr.h", line 4631
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 7134
    handle_print(x);
  File "/Users/brian/CLionProjects/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 7333
    throw LCompilersException("Printing support is not available for " +
LCompilersException: Printing support is not available for dict type.```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions