Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASR -> CPython: Add SetConstant visitor #2692

Closed

Conversation

kmr-srbh
Copy link
Contributor

@kmr-srbh kmr-srbh commented May 9, 2024

Global scope

from lpython import i32, f64

my_first_set: set[i32] = {1, 2, 3, 2, 4}
print(my_first_set)

my_second_set: set[f64] = {1.1, 2.5, 6.8}
print(my_second_set)

my_third_set: set[str] = {"a", "b", "a", "c"}
print(my_third_set)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py --show-python
def __main__global_init():
    my_first_set = {1, 2, 3, 2, 4}
    my_second_set = {1.100000, 2.500000, 6.800000}
    my_third_set = {"a", "b", "a", "c"}
def __main__global_stmts():
    print(my_first_set)
    print(my_second_set)
    print(my_third_set)

Local scope

from lpython import i32, f64


def f():
    my_first_set: set[i32] = {1, 2, 3, 2, 4}
    print(my_first_set)

    my_second_set: set[f64] = {1.1, 2.5, 6.8}
    print(my_second_set)

    my_third_set: set[str] = {"a", "b", "a", "c"}
    print(my_third_set)


f()
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py --show-python
def __main__global_stmts():
    f()
def f():
    my_first_set: set[i32]
    my_second_set: set[f64]
    my_third_set: set[str]
    my_first_set = {1, 2, 3, 2, 4}
    print(my_first_set)
    my_second_set = {1.100000, 2.500000, 6.800000}
    print(my_second_set)
    my_third_set = {"a", "b", "a", "c"}
    print(my_third_set)

TODO

  • Add tests

@nikabot
Copy link

nikabot commented May 9, 2024

See: #2690 (comment)

@kmr-srbh
Copy link
Contributor Author

kmr-srbh commented May 9, 2024

Closing due to #2690 (comment)

@kmr-srbh kmr-srbh closed this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants