Skip to content

Bug: Declaration and Print Statements with Dictionary Key as a String type not working #1590

Closed
@harshsingh-24

Description

@harshsingh-24

Test Case 1 (dict_string.py):

def fun():
    y : dict[str, i32]
    y = {"apple": 1}
    print(y["apple"])

fun()
  • Normal Python Output:
1
  • LPython Output (when inst\bin\lpython examples/dict_string.py was executed
# NO OUTPUT WITNESSED. 

Unknown behavior of print statement was observed. Without throwing any error or warning, the program just terminates abruptly for me.

Test Case 2 (dict_string.py)

def fun():
    x : dict[i32, i32] = {1: 2}
    print(x[1])

    y : dict[str, i32]
    y = {"apple": 1}
    print(y["apple"])

fun()
  • Normal Python Output:
2
1
  • LPython Output (when inst\bin\lpython examples/dict_string.py was executed
code generation error: Variable type not supported 12
 --> examples/dict_string.py:5:5
  |
5 |     y : dict[str, i32]
  |     ^^^^^^^^^^^^^^^^^^

Does the dictionary has support for string data types yet or not?
@czgdp1807 @Thirumalai-Shaktivel

Metadata

Metadata

Assignees

No one assigned

    Labels

    could closeIssues/PRs which can be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions