Topaz
Run with the Topaz compiler 5.21.1
main.tpzimport std.io
io.writeLine("시작")
let result = "3" + 4
io.writeLine("{result}")
Commands
Run
topaz run main.tpzExit status 1Standard output Empty
Standard error error[TPZ5001]: `+` needs matching int, float, string, BigInt, or Decimal operands, found `string` and `int` --> main.tpz:4:14 | 4 | let result = "3" + 4 | ^^^^^^^ main.tpz: 1 type diagnostic
In plain words
topaz run stopped at "3" + 4 on line 4. It reports TPZ5001, which says this + cannot take a string (string) and an integer (int) together.
It ended with this error, so even the 시작 it was meant to print first was never printed.
The last line of the error, 1 type diagnostic, marks it as an error found by the type check.
Running topaz check on the same file gave the same error.
This language’s rule
Topaz checks the types on both sides of + before the program runs. To join text, both sides must be strings.
Show the extra recordsHide the extra records
Check
topaz check main.tpzExit status 1Standard output Empty
Standard error error[TPZ5001]: `+` needs matching int, float, string, BigInt, or Decimal operands, found `string` and `int` --> main.tpz:4:14 | 4 | let result = "3" + 4 | ^^^^^^^ main.tpz: 1 type diagnostic
With "3" + "4" instead, which adds two strings, topaz run printed 시작 and 34 and finished.
control-string-plus-string.tpzimport std.io
io.writeLine("시작")
let result = "3" + "4"
io.writeLine("{result}")
Run
topaz run control-string-plus-string.tpzExit status 0Standard output 시작 34Standard error Empty