fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

String literal with embedded expressions is not shown well in error message

Open fridis opened this issue 3 months ago • 0 comments

The following code is ok, it is showing the whole string literal as the error location

> FUZION_DISABLE_ANSI_ESCAPES=true ../clean/fuzion.5/build/bin/fz -e 'ignore i32 "abcdunitefgt"'

command line:1:12: error 1: Incompatible types when passing argument in a call
ignore i32 "abcdunitefgt"
-----------^^^^^^^^^^^^^^
Actual type for argument #1 'x' does not match expected type.
In call to          : 'ignore'
expected formal type: 'i32'
actual type found   : 'String'
assignable to       : 'String'
for value assigned  : '"abcdunitefgt"'
To solve this, you could change the type of the target 'x' to 'String' or convert the type of the assigned value to 'i32'.

one error.

however, if the string uses embedded expressions like {unit}, the error location is some point in the string and no longer the whole string:

 > FUZION_DISABLE_ANSI_ESCAPES=true ../clean/fuzion.5/build/bin/fz -e 'ignore i32 "abcd{unit}efgt"'

command line:1:22: error 1: Incompatible types when passing argument in a call
ignore i32 "abcd{unit}efgt"
---------------------^
Actual type for argument #1 'x' does not match expected type.
In call to          : 'ignore'
expected formal type: 'i32'
actual type found   : 'String'
assignable to       : 'String'
for value assigned  : '"abcd{unit}efgt"'
To solve this, you could change the type of the target 'x' to 'String' or convert the type of the assigned value to 'i32'.

one error.

fridis avatar Sep 25 '25 10:09 fridis