(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
semantic error: Type mismatch in index, expected a single integer or slice
--> ./examples/example.py:4:9
|
4 | print(d["a"])
| ^^^ type mismatch (found: 'str', expected: 'i32' or slice)
Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
ASR verify pass error: ASR verify: The variable in ArrayItem must be an array, not a scalar
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
Binary file "/home/saurabh-kumar/Projects/System/lpython/src/bin/lpython", in _start()
File "./csu/../csu/libc-start.c", line 360, in __libc_start_main_impl()
File "./csu/../sysdeps/x86/libc-start.c", line 58, in __libc_start_call_main()
File "/home/saurabh-kumar/Projects/System/lpython/src/bin/lpython.cpp", line 1873, in main()
err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
File "/home/saurabh-kumar/Projects/System/lpython/src/bin/lpython.cpp", line 787, in compile_python_to_object_file()
!(arg_c && compiler_options.po.disable_main), "__main__", infile);
LCompilersException: Verify failed
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
ASR verify pass error: ASR verify: The variable in ArrayItem must be an array, not a scalar
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
Binary file "/home/saurabh-kumar/Projects/System/lpython/src/bin/lpython", in _start()
File "./csu/../csu/libc-start.c", line 360, in __libc_start_main_impl()
File "./csu/../sysdeps/x86/libc-start.c", line 58, in __libc_start_call_main()
File "/home/saurabh-kumar/Projects/System/lpython/src/bin/lpython.cpp", line 1873, in main()
err = compile_python_to_object_file(arg_file, tmp_o, runtime_library_dir,
File "/home/saurabh-kumar/Projects/System/lpython/src/bin/lpython.cpp", line 787, in compile_python_to_object_file()
!(arg_c && compiler_options.po.disable_main), "__main__", infile);
LCompilersException: Verify failed
Fix
Check for Const type when handling subscript indices and do required processing for mutable types like dict and list. For types which are already immutable, like str and tuple, throw an error stating that Const is not required.
Overview
Accessing values from a data-structure contained within
Const
fails with different errors for different data-structures.Dictionary
List
Tuple
String
Fix
Check for
Const
type when handling subscript indices and do required processing for mutable types likedict
andlist
. For types which are already immutable, likestr
andtuple
, throw an error stating thatConst
is not required.