diff options
author | flywind <xzsflywind@gmail.com> | 2021-03-29 23:54:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 17:54:28 +0200 |
commit | 7ad49950bd5ec05f145dc43ae35f51127ea76366 (patch) | |
tree | fd76576efa7259fa6163c77577017e50253398b0 | |
parent | d23a75776555b998ccee83fe2f2c498e2144ec86 (diff) | |
download | Nim-7ad49950bd5ec05f145dc43ae35f51127ea76366.tar.gz |
[os:standalone]fix #14011 (#17564)
-rw-r--r-- | lib/system/chcks.nim | 10 | ||||
-rw-r--r-- | tests/gc/panicoverride.nim | 14 | ||||
-rw-r--r-- | tests/gc/tstandalone.nim | 14 |
3 files changed, 36 insertions, 2 deletions
diff --git a/lib/system/chcks.nim b/lib/system/chcks.nim index e0a8bd78e..255d97cb2 100644 --- a/lib/system/chcks.nim +++ b/lib/system/chcks.nim @@ -29,10 +29,16 @@ proc raiseFieldError(f: string) {.compilerproc, noinline.} = sysFatal(FieldDefect, f) proc raiseRangeErrorI(i, a, b: BiggestInt) {.compilerproc, noinline.} = - sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b) + when defined(standalone): + sysFatal(RangeDefect, "value out of range") + else: + sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b) proc raiseRangeErrorF(i, a, b: float) {.compilerproc, noinline.} = - sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b) + when defined(standalone): + sysFatal(RangeDefect, "value out of range") + else: + sysFatal(RangeDefect, "value out of range: " & $i & " notin " & $a & " .. " & $b) proc raiseRangeErrorU(i, a, b: uint64) {.compilerproc, noinline.} = # todo: better error reporting diff --git a/tests/gc/panicoverride.nim b/tests/gc/panicoverride.nim new file mode 100644 index 000000000..0f28b0b72 --- /dev/null +++ b/tests/gc/panicoverride.nim @@ -0,0 +1,14 @@ + +proc printf(frmt: cstring) {.varargs, importc, header: "<stdio.h>", cdecl.} +proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.} + +{.push stack_trace: off, profiler:off.} + +proc rawoutput(s: string) = + printf("%s\n", s) + +proc panic(s: string) {.noreturn.} = + rawoutput(s) + exit(1) + +{.pop.} \ No newline at end of file diff --git a/tests/gc/tstandalone.nim b/tests/gc/tstandalone.nim new file mode 100644 index 000000000..41dad9ba4 --- /dev/null +++ b/tests/gc/tstandalone.nim @@ -0,0 +1,14 @@ +discard """ + matrix: "--os:standalone --gc:none" + exitcode: 1 + output: "value out of range" +""" + +type + rangeType = range[0..1] + +var + r: rangeType = 0 + i = 2 + +r = rangeType(i) |