Fix LiteralUTF8Char lowering for non-ASCII UTF-8 chars#207
Open
tmdeveloper007 wants to merge 1 commit intoarxlang:mainfrom
Open
Fix LiteralUTF8Char lowering for non-ASCII UTF-8 chars#207tmdeveloper007 wants to merge 1 commit intoarxlang:mainfrom
tmdeveloper007 wants to merge 1 commit intoarxlang:mainfrom
Conversation
Member
|
@tmdeveloper007 , the tests currently only testing that LLVM IR generation doesn't crash, not that the UTF-8 character lowering is correct. |
yuvimittal
reviewed
Mar 10, 2026
| char_literal = astx.LiteralUTF8Char(expected) | ||
|
|
||
| decl_tmp = astx.VariableDeclaration( | ||
| name="tmp", type_=astx.String(), value=char_literal |
Member
There was a problem hiding this comment.
what is the use of tmp here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request description
This PR fixes a Unicode lowering bug in
LiteralUTF8Char.When lowering
astx.LiteralUTF8Char, the code correctly computed the UTF-8 byte length, but initialized the backing global constant using ASCII encoding. That caused translation to fail for valid non-ASCII characters such aséwith aUnicodeEncodeError.Changes made:
LiteralUTF8CharstorageAddresses #208
How to test these changes
pytest tests/test_string.py -q -k "utf8_char_non_ascii_translate"astx.LiteralUTF8Char("é")no longer raisesUnicodeEncodeErrorPull Request checklists
This PR is a:
About this PR:
Author's checklist:
complexity.
Additional information
pytest tests/test_string.py -q -k "utf8_char_non_ascii_translate"ruff check src/irx/builders/llvmliteir.py tests/test_string.pyReviewer's checklist
Copy and paste this template for your review's note: