Skip to content

Commit

Permalink
Fixed Issue #6929 Escape unicode when inspecting a Str (#7411)
Browse files Browse the repository at this point in the history
* Fixed Issue #6929 Escape unicode when inspecting Str

added AUTHORS

improved comment

* update generated mono tests

* fixed formatting

* fixed merge conflicts
  • Loading branch information
timonkrebs authored Jan 6, 2025
1 parent 89ef225 commit 716374c
Show file tree
Hide file tree
Showing 19 changed files with 3,332 additions and 1,022 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ Isak Jones <[email protected]>
Ch1n3du <[email protected]>
Elias Mulhall <[email protected]>
ABuffSeagull <[email protected]>
Timon Krebs <[email protected]>
9 changes: 8 additions & 1 deletion crates/compiler/builtins/roc/Inspect.roc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,14 @@ dbgStr = \s ->
custom \f0 ->
f0
|> dbgWrite "\""
|> dbgWrite s # TODO: Should we be escaping strings for dbg/logging?
|> \f1 ->
# escape invisible unicode characters as in fmt_str_body crates/compiler/fmt/src/expr.rs
escapeS =
Str.replaceEach s "\u(feff)" "\\u(feff)"
|> Str.replaceEach "\u(200b)" "\\u(200b)"
|> Str.replaceEach "\u(200c)" "\\u(200c)"
|> Str.replaceEach "\u(200d)" "\\u(200d)"
dbgWrite f1 escapeS
|> dbgWrite "\""

dbgOpaque : * -> Inspector DbgFormatter
Expand Down
54 changes: 27 additions & 27 deletions crates/compiler/test_mono/generated/dbg_expr.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 716374c

Please sign in to comment.