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

WASM: Unescape string #1756

Closed
wants to merge 2 commits into from
Closed

Conversation

Shaikh-Ubaid
Copy link
Collaborator

Expected:

$ lpython integration_tests/print_01.py                          
Hello World!
a,b
a-+-+-b-+-+-c
d=e=f+
x*
y*
z!!1:2
LCompilers LPython

Main branch:

$ lpython integration_tests/print_01.py --backend wasm -o tmp.out
$ wasmtime tmp.out                                               
Hello World!
a,b
a-+-+-b-+-+-c
d=e=f+\nx*\ny*\nz!!1:2
LCompilers LPython

PR branch:

$ lpython integration_tests/print_01.py --backend wasm -o tmp.out     
$ wasmtime tmp.out
Hello World!
a,b
a-+-+-b-+-+-c
d=e=f+
x*
y*
z!!1:2
LCompilers LPython

@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as ready for review May 3, 2023 10:06
@@ -2084,8 +2084,9 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {
}

void visit_StringConstant(const ASR::StringConstant_t &x) {
emit_string(x.m_s);
m_wa.emit_i32_const(m_string_to_iov_loc_map[x.m_s]);
std::string s = unescape_string(m_al, x.m_s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string should have been unescaped in ASR already. See #1759.

So the proper fix for this is to fix the frontend to keep the string unescaped.

@@ -295,7 +295,7 @@ RUN(NAME exit_02b FAIL LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME exit_02c FAIL LABELS cpython llvm c)

# Test all four backends
RUN(NAME print_01 LABELS cpython llvm c wasm) # wasm not yet supports sep and end keywords
RUN(NAME print_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is good

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will enable this test in one of the upcoming PRs.

@certik certik marked this pull request as draft May 4, 2023 17:00
@Shaikh-Ubaid
Copy link
Collaborator Author

Closing in favour of #1762.

@Shaikh-Ubaid Shaikh-Ubaid deleted the wasm_unescape branch May 9, 2023 16:02
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.

3 participants