Skip to content

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

@kayabaNerve

Description

@kayabaNerve

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.

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

Current Output

abc5

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions