summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2021-10-07 10:07:27 +0200
committerBjörn Gustavsson <bjorn@erlang.org>2021-10-14 04:59:22 +0200
commitc9bb64f18b7dc3b3a375f99c529c069656519192 (patch)
treeb34f470cfaccca473d2e10118aee31b3efe7dab4
parenta9cbf22724c648d10c0eae3eb2221671cd8f1360 (diff)
downloaderlang-c9bb64f18b7dc3b3a375f99c529c069656519192.tar.gz
sys_core_fold: Don't replace bad binary segments with error(badarg)
Keep warnings for binary construction that will fail, but don't replace the construction with an `error(badarg)` call to allow the runtime system to add extended information to the exception. For example, `sys_core_fold` will no longer replace the following code: <<F:7/float>> with a call to `error(badarg)`. However, note that v3_core still replaces obviously bad types and sizes with a call to `error(badarg)`. For example, `v3_core` will replace the following construction with a call to `error(badarg)`: <<atom:32>>
-rw-r--r--lib/compiler/src/sys_core_fold.erl5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index 3653d5e647..7a0bf0c34e 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -601,10 +601,7 @@ eval_binary(#c_binary{anno=Anno,segments=Ss}=Bin) ->
Bin;
throw:{badarg,Warning} ->
add_warning(Bin, {failed,Warning}),
- #c_call{anno=Anno,
- module=#c_literal{val=erlang},
- name=#c_literal{val=error},
- args=[#c_literal{val=badarg}]}
+ Bin
end.
eval_binary_1([#c_bitstr{val=#c_literal{val=Val},size=#c_literal{val=Sz},