Unsound use of metaprogramming quotes: future-stage type evidence shouldn't be usable in the current stage #9353
Labels
area:gadt
area:metaprogramming:quotes
Issues related to quotes and splices
itype:bug
itype:soundness
Soundness bug (it lets us compile code that crashes at runtime with a ClassCastException)
While reviewing my thesis, Oleg Kiselyov pointed out a subtlety in the interaction of GADTs with staging in MetaOCaml: GADT constraints should be marked by stage to prevent the use of future-stage constraints in the current stage, which would be unsound. He gave the following example, which is a test in the MetaOCaml distribution:
(As an answer to the problem, MetaOCaml rejects pattern-matches of GADTs within quotes, so that does not compile.)
Sure enough, we can reproduce something similar in Scala, without even having to use a GADT, since Scala has first-class support for subtype evidence:
The text was updated successfully, but these errors were encountered: