토파즈
토파즈 컴파일러 5.21.1로 실행한 기록
main.tpzimport std.io
io.writeLine("시작")
let result = "3" + 4
io.writeLine("{result}")
명령
실행
topaz run main.tpz종료 상태 1표준 출력 비어 있음
표준 오류 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
쉬운 풀이
topaz run은 4번째 줄의 "3" + 4에서 멈췄어. 문자열(string)과 정수(int)는 이 +로 함께 쓸 수 없다는 TPZ5001 오류야.
이 오류를 내고 끝나서, 맨 먼저 찍으려던 시작도 찍히지 않았어.
오류 끝줄의 1 type diagnostic은 타입 검사에서 나온 오류라는 표시야.
같은 파일에 topaz check를 따로 해 봐도 같은 오류가 나왔어.
이 언어의 규칙
토파즈는 실행 전에 + 양쪽의 타입을 확인해. 문자열을 이으려면 양쪽 모두 문자열이어야 해.
함께 돌려 본 기록 보기함께 돌려 본 기록 접기
검사
topaz check main.tpz종료 상태 1표준 출력 비어 있음
표준 오류 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
문자열 둘을 더하는 "3" + "4"로 바꿔 topaz run으로 돌리면 시작과 34를 찍고 끝났어.
control-string-plus-string.tpzimport std.io
io.writeLine("시작")
let result = "3" + "4"
io.writeLine("{result}")
실행
topaz run control-string-plus-string.tpz종료 상태 0표준 출력 시작 34
표준 오류 비어 있음