diff options
author | 2017-07-26 15:28:18 +0200 | |
---|---|---|
committer | 2017-07-26 15:28:18 +0200 | |
commit | bd1a0abf49fe67e7f02dc562d4b81d27ed6f606c (patch) | |
tree | 3c090952c7931e03ceaf83e1b1f0fec06af711e2 /test-suite | |
parent | 941f92a8b623b3d79fb0802e0b47709a7b50f275 (diff) | |
parent | eca3f65315aae5923bd3d6dc6c3dcfe20da8866b (diff) |
Merge PR #918: Extraction: do not mix Haskell types Any and () (fix bugs 4844 and 4824)
Diffstat (limited to 'test-suite')
-rw-r--r-- | test-suite/bugs/closed/4844.v | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test-suite/bugs/closed/4844.v b/test-suite/bugs/closed/4844.v new file mode 100644 index 000000000..f140939cc --- /dev/null +++ b/test-suite/bugs/closed/4844.v @@ -0,0 +1,47 @@ + +(* Bug report 4844 (and 4824): + The Haskell extraction was erroneously considering [Any] and + [()] as convertible ([Tunknown] an [Tdummy] internally). *) + +(* A value with inner logical parts. + Its extracted type will be [Sum () ()]. *) + +Definition semilogic : True + True := inl I. + +(* Higher-order record, whose projection [ST] isn't expressible + as an Haskell (or OCaml) type. Hence [ST] is extracted as the + unknown type [Any] in Haskell. *) + +Record SomeType := { ST : Type }. + +Definition SomeTrue := {| ST := True |}. + +(* A first version of the issue: + [abstrSum] is extracted as [Sum Any Any], so an unsafeCoerce + is required to cast [semilogic] into [abstrSum SomeTrue]. *) + +Definition abstrSum (t : SomeType) := ((ST t) + (ST t))%type. + +Definition semilogic' : abstrSum SomeTrue := semilogic. + +(* A deeper version of the issue. + In the previous example, the extraction could have reduced + [abstrSum SomeTrue] into [True+True], solving the issue. + It might do so in future versions. But if we put an inductive + in the way, a reduction isn't helpful. *) + +Inductive box (t : SomeType) := Box : ST t + ST t -> box t. + +Definition boxed_semilogic : box SomeTrue := + Box SomeTrue semilogic. + +Require Extraction. +Extraction Language Haskell. +Recursive Extraction semilogic' boxed_semilogic. +(* Warning! To fully check that this bug is still closed, + you should run ghc on the extracted code: + +Extraction "bug4844.hs" semilogic' boxed_semilogic. +ghc bug4844.hs + +*) |