[erlang-patches] Scan "=<<" as something useful
Anthony Ramine
n.oxyde@REDACTED
Fri Jun 7 18:22:29 CEST 2013
Nothing to reply to this?
--
Anthony Ramine
Le 1 mai 2013 à 15:14, Anthony Ramine a écrit :
> Hello Raimo,
>
> I've given some more thought about that subject and whether the fix could surprise people if they ever did a typo.
>
> 1/ "A=<<<1>>" ("A =< << 1 >>") instead of "A=<<1>>" ("A = << 1 >>")
>
> * If A is not bound, this is a compilation error. The intended code would have compiled fine.
> * If A is bound, the intended code is to crash if A isn't <<1>>, that kind of quick and dirty check is usually to fail early and found not nested in a function body; the typo is a comparison expression and the compiler will complain its return value is not used.
> * If A is bound and the expression's return value used, no compilation error or warning will be triggered but Dialyzer will complain about a binary/boolean type mismatch.
>
> 2/ "A=<<1>>" ("A = << 1 >>") instead of "A=<<<1>>" ("A =< << 1 >>")
>
> * If A isn't bound, code compiles just fine. The intended code would have failed with a compilation error.
> * If A is bound, no compilation error but Dialyzer will complain of a binary/boolean type mismatch.
>
> So we are left with two cases where the compiler will say nothing, but Dialyzer will.
>
> Regards,
>
> --
> Anthony Ramine
>
> Le 29 avr. 2013 à 15:32, Raimo Niskanen a écrit :
>
>> On Mon, Apr 29, 2013 at 03:11:44PM +0200, Anthony Ramine wrote:
>>> I don't understand how is that a typo, as "A=<<<1>>" is valid syntax with or without my patch.
>>
>> ...i misread the old arguments; rather that intending to write "A =< << 1 >>"
>> without spaces as "A=<<<1>>" and misspelling to "A=<<1>>" would give no compiler
>> error and unexpected runtime behaviour...
>>
>>>
>>> --
>>> Anthony Ramine
>>>
>>> Le 29 avr. 2013 à 15:05, Raimo Niskanen a écrit :
>>>
>>>> One final straw back then was this: the typo "A=<<<1>>" accidentally
>>>> becomes valid syntax with the proposed change.
>>>
>>
>> --
>>
>> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>> _______________________________________________
>> erlang-patches mailing list
>> erlang-patches@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-patches
>
More information about the erlang-patches
mailing list