Skip to content

Conversation

@amritamishra01
Copy link

This Pull Request adds a new semantic error test to ensure LPython correctly rejects assignments to literal values.

✔ What this PR does

Adds a new test: tests/errors/reproduce_bug_01.py

The test checks that assigning to a literal (e.g., 'a' = 1) raises the expected SyntaxError: cannot assign to literal.

Adds the corresponding .out file with the correct error output.

Updates python_ast_to_asr.cpp by adding a semantic check:

Detects assignment targets that are literals (Constant, Set, Dict)

Throws a SemanticError with a clear and correct message.

✔ Why this is important

Python does not allow assignment to literal values.
This PR ensures LPython’s semantic analysis matches Python’s behavior and provides a clear error message.

✔ How it was tested

Ran the single test using:

python3 run_tests.py -t tests/errors/reproduce_bug_01.py

Test passes successfully.

@amritamishra01
Copy link
Author

Hi! I’ve applied all the requested review changes (removed debug prints, fixed headers, and used the precise AST node types).

Linux, Windows, and WASM CI all pass successfully.
Only the macOS CI is failing due to a GitHub Actions toolchain issue:

ld: warning: object file was built for newer 'macOS' version (15.0)
than being linked (14.0)

This warning gets captured in stderr and causes
runtime-test_list_index.py to fail due to a mismatching stderr hash.

This failure is unrelated to the changes in this PR.
Could you please re-run the macOS job or update the macOS reference output on your side?

Thank you!

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.

1 participant