Compile-time type hierarchy information in pattern switch
peter.levart at gmail.com
Thu Apr 5 21:20:11 UTC 2018
On 04/05/18 22:28, Remi Forax wrote:
> the way to detect it is to use the DAG of the supertypes (lazily constructed*), from the last to the first case, the idea is to propagate the index of down to the super types, if during the propagation, you find a supertype which is also a case and with an index lower that the currently propagated, then it's a failure.
> * you do not have to actually create the DAG, just be able to traverse it from the subtype to the supertypes.
Yes, this idea is similar to mine. We just have to find a conflict
between subtype relationships and compile time order of cases which
could be viewed as forming implicit pair-by-pair relationships of
consecutive cases. If there's a cycle, we have a conflict.
More information about the amber-spec-observers