PATCH: R13B01: new() function with module parameter variable(s) in guard crashes compiler

Yurii Rashkovskii <>
Mon Aug 17 15:36:22 CEST 2009


Hello,

Currently, R13B01's compiler crashes on source code like this:

-module(somemodule,[P1]).
-compile(export_all).

new() when P1 > 0 ->
     instance(hello).

The crash looks like this:

./somemodule.erl:none: internal error in core_dsetel_module;
crash reason: {{badmatch,error},
                [{sys_core_dsetel,visit,2},
                 {lists,mapfoldl,3},
                 {sys_core_dsetel,visit,2},
                 {sys_core_dsetel,visit,2},
                 {lists,mapfoldl,3},
                 {sys_core_dsetel,visit,2},
                 {sys_core_dsetel,visit,2},
                 {sys_core_dsetel,visit_module_1,3}]}

Attached you can find a quick patch that makes compiler emit an error  
instead:

./somemodule.erl:4: variable 'P1' is unbound

This patch is also available through this branch: http://github.com/yrashk/erlang/commits/compiler-new-guards-use-of-parameters

The solution in this patch might not be ideal, but it is a start; if  
OTP team will be interested in including it into official source code  
tree, I will be happy to spend a little bit more time to make it  
somewhat nicer.

Thanks,
Yurii.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: compiler-new-guards-use-of-parameters.diff
Type: application/octet-stream
Size: 930 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20090817/cb08216b/attachment.obj>
-------------- next part --------------



More information about the erlang-patches mailing list