[erlang-questions] Dialyzer vs re:compile(..., [unicode])

Kostis Sagonas kostis@REDACTED
Wed Dec 22 11:28:08 CET 2010


Attila Rajmund Nohl wrote:
> Hello!
> 
> I have this small example code, compiled with OTP R14B01:
> 
> -module(d).
> 
> -export([f/0]).
> 
> f() ->
>     {ok, MP} = re:compile("abcd", [unicode]).
> 
> when I try to analyze it with dialyzer, I get this error:
> 
> d.erl:6: The call re:compile("abcd",['unicode',...]) will never return
> since it differs in the 2nd argument from the success typing
> arguments: (binary() | maybe_improper_list(binary() |
> maybe_improper_list(any(),binary() | []) | byte(),binary() |
> []),['anchored' | 'caseless' | 'dollar_endonly' | 'dotall' |
> 'dupnames' | 'extended' | 'firstline' | 'multiline' |
> 'no_auto_capture' | 'ungreedy' | {'newline','anycrlf' | 'cr' | 'crlf'
> | 'lf'}])
> 
> But according to the documentation the re:compile should (and in
> practice does) accept the unicode parameter. Unfortunately this error
> cascades up, i.e. dialyzer warns about many code which eventually
> calls re:compile with unicode parameter, leading to many false
> positives. Is there a simple fix for this?

Yes. Unfortunately R14B01 was shipped with this feature (and some other 
ones...). But the problem has already been fixed and the fix already 
appears in OTP's 'dev'.

It's also here:

    https://github.com/kostis/otp/tree/r14b01-patch

Kostis


More information about the erlang-questions mailing list