[clean-list] Pattern matching

Diederik van Arkel dvanarkel@mac.com
Sun, 5 Jan 2003 18:13:11 +0100


On Sunday, January 5, 2003, at 05:37 PM, Fergus Henderson wrote:

> On 04-Jan-2003, Diederik van Arkel <dvanarkel@mac.com> wrote:
>>
>> On Saturday, January 4, 2003, at 09:30 AM, Dmitry Malenko wrote:
>>
>>> s x     = 3*x
>>> s [x]   = 2*x
>>> s [x,y] = x*y
>>>
>>> Start = s 4
>>>
>>> When compile it I get warning: "[test.icl,5,s] alternative will never
>>> match". Nevertheless program runs perfectly and gives expected result
>>> 12.
>>
>> What's happening here is that apparently the compiler throws away the
>> second and
>> third alternatives for s because the first alternative wil always
>> succeed. It does
>> this before typechecking and therefore does not notice that the types
>> of these
>> alternatives are inconsistent.
>
> Presumably this behaviour is a (minor) bug in the Clean compiler...
> it ought to do type checking before applying such optimizations, right?
>

Presumably yes, hence the cc to the bug reporting address (clean@...).

Regards,

Diederik van Arkel