[clean-list] Serious bug in the type system
John van Groningen
johnvg at cs.ru.nl
Wed Jan 2 16:34:33 MET 2008
Edsko de Vries wrote:
>...
> > For unique arrays with unboxed values this may not be necessary, it may be
> > correct to type these as observers.
>
>I don't understand your last remark; with unboxed values, 'ohoh' is
>already rejected by the compiler:
>
> ohoh :: *{Char} -> *(*{Char}, {Char})
> ohoh arr
> #! arr` = arr
> = (update arr 0 'a', arr`)
>
>gives
>
> Uniqueness error [t.icl,5,ohoh]: "arr" demanded attribute cannot be
> offered by shared object
There are no arrays with unboxed values in this example. {#Char} is an array
of unboxed evaluated characters. {Char} is an array of boxed, possibly
unevaluated characters.
>This makes sense, since unboxed values can have thunks inside them, thus
>violating the hyperstrict condition -- no?
Yes, your example violates the hyperstrict condition, and is therefore
rejected by the compiler.
An example of a unique array with (only) unboxed values for which typing
as an observer may be correct is:
copy2 :: !*{#Int} -> (!*{#Int},!*{#Int})
copy2 a1
#! a2=copy a1
= (a2,a1)
copy :: {#Int} -> *{#Int}
copy a = {e\\e<-:a}
The Clean 2.2 compiler allows this because of the bug. After fixing the bug
it is rejected. This is not necessary, because the result of copy must be a
newly created array, because no unique array is passed to function copy.
Kind regards.
John van Groningen
More information about the clean-list
mailing list