ISLE: handle out-of-order extern converter decls. (#4079)

This fixes a bug where the ISLE compiler would refuse to accept
out-of-order declarations in the order of: (i) use of an implicit
conversion backed by an extern constructor; (ii) extern declaration
for that constructor.

The issue was one of phase separation: we were capturing and noting
"extern constructor" status on terms in the same pass in which we were
typechecking and resolving implicit conversions. Given this knowledge,
the fix is straightforward: externs are picked up in a prior pass.
This commit is contained in:
Chris Fallin
2022-04-28 11:16:46 -07:00
committed by GitHub
parent 936f4efd6a
commit 477d394288
2 changed files with 88 additions and 56 deletions

View File

@@ -0,0 +1,22 @@
(type T (primitive T))
(type U (primitive U))
(type V (primitive V))
(convert T U t_to_u)
(type Result (enum (T (u U) (v V))))
;; Use the implicit converter before the underlying constructor is
;; declared (below). Also use one of the conversions before it is
;; declared (below).
(decl entry (T) Result)
(rule (entry t)
(Result.T t t))
(convert T V t_to_v)
(decl t_to_u (T) U)
(extern constructor t_to_u t_to_u)
(decl t_to_v (T) V)
(rule (t_to_v _) 0)