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

[BUG] Standard library replace function fails to replace backslash characters #589

Open
lens0021 opened this issue Nov 13, 2024 · 3 comments · May be fixed by #592
Open

[BUG] Standard library replace function fails to replace backslash characters #589

lens0021 opened this issue Nov 13, 2024 · 3 comments · May be fixed by #592
Labels
bug Something isn't working stdlib

Comments

@lens0021
Copy link

lens0021 commented Nov 13, 2024

Describe the bug

To Reproduce

$ amber -e 'import * from "std/text"; echo replace("\\", "\\", "expected")'
\
$ amber -e 'import * from "std/text"; echo replace("\\\\", "\\\\", "expected")'
expectedexpected

Tested on both the latest release(0.3.5-alpha) and on the current latest commit(825f280).

Expected behavior

$ amber -e 'import * from "std/text"; echo replace("\\", "\\", "expected")'
expected
$ amber -e 'import * from "std/text"; echo replace("\\\\", "\\\\", "expected")'
expected

Additional context
This is very similar to #481

@lens0021 lens0021 added the bug Something isn't working label Nov 13, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Nov 13, 2024
@Mte90 Mte90 added the stdlib label Nov 14, 2024
@Ph0enixKM Ph0enixKM added this to the Amber 0.4.0-alpha milestone Nov 14, 2024
@Ph0enixKM
Copy link
Member

I'd like to fix this one before 0.4.0-alpha release. It seems weird that it works. It's some kind of escaping bug

@Ph0enixKM
Copy link
Member

@Mte90 It seems that replacing backslash with the bash substitution does not work at all

Screenshot 2024-11-14 at 18 52 19

@Ph0enixKM
Copy link
Member

Btw I think that we should rename these function so that they're called the same way Javascript's functions are:

  • replace
  • replace_all
Screenshot 2024-11-14 at 18 58 50

@lens0021 lens0021 linked a pull request Nov 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stdlib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants