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

`str &= data` doesn't behave as `str = str & data`. #10963

kayabaNerve opened this issue Apr 4, 2019 · 2 comments


None yet
5 participants
Copy link

commented Apr 4, 2019

If a string and an int are combined via &, a compilation error occurs. When combined via &=, the int is converted to a string via $ and the code compiles. This error doesn't occur in Nimscript, and is localized to Nim.

    a: string = "abc"
    b: int = 5
a &= b
echo a

Current Output


Expected Output

Compilation Error of Error: type mismatch: got <string, int>

Tested on 0.19.0, 0.19.4, and devel (compiled as this issue was written). All three had Nimscript (tested via nim secret) throw an error, but Nim compile.


This comment has been minimized.

Copy link

commented Apr 5, 2019

According to Araq on IRC this is caused by an add proc that takes a string and an int, which I assume is this one:

EDIT: And the rewrite seems to happen here: commenting out that and adding a procedure that takes string + char works fine for compiling Nim itself. Not sure if any library out there uses this though..


This comment has been minimized.

Copy link

commented Apr 5, 2019

I think a & overload for string, int should be in sugar.nim or lenientops.nim, same thing for &=.

Tagging RFC as it's more of a system.nim / standard library design question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.