diff options
Diffstat (limited to 'libgo/runtime/go-runtime-error.c')
-rw-r--r-- | libgo/runtime/go-runtime-error.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libgo/runtime/go-runtime-error.c b/libgo/runtime/go-runtime-error.c index 5edbeeb..f1c1650 100644 --- a/libgo/runtime/go-runtime-error.c +++ b/libgo/runtime/go-runtime-error.c @@ -60,16 +60,29 @@ extern void __go_runtime_error (int32) __attribute__ ((noreturn)); void __go_runtime_error (int32 i) { + struct funcfileline_return fileline; + bool in_runtime; + + fileline = runtime_funcfileline ((uintptr) runtime_getcallerpc(), 0); + in_runtime = (fileline.retfn.len > 0 + && (__builtin_strncmp ((const char *) fileline.retfn.str, + "runtime.", 8) + == 0)); + switch (i) { case SLICE_INDEX_OUT_OF_BOUNDS: case ARRAY_INDEX_OUT_OF_BOUNDS: case STRING_INDEX_OUT_OF_BOUNDS: + if (in_runtime) + runtime_throw ("index out of range"); runtime_panicstring ("index out of range"); case SLICE_SLICE_OUT_OF_BOUNDS: case ARRAY_SLICE_OUT_OF_BOUNDS: case STRING_SLICE_OUT_OF_BOUNDS: + if (in_runtime) + runtime_throw ("slice bounds out of range"); runtime_panicstring ("slice bounds out of range"); case NIL_DEREFERENCE: |