In the following sample code,
var n : nat ;; <--- problematic
def $f(nat*) : nat
def $f(n*) = n'
-- if n* = n_1'* n_2*
-- if n_1'* = n_1* n'
With the var declaration, it's elaborated into:
;; juxt.spectec:3.1-3.19
def $f(nat*) : nat
;; juxt.spectec:4.1-6.24
def $f{`n*` : nat*, n' : nat, `n_1'*` : nat*, `n_2*` : nat*, `n_1*` : nat*}(n*{n <- `n*`}) = n'
-- if ([n*{n <- `n*`}] = [n_1'*{n_1' <- `n_1'*`} n_2*{n_2 <- `n_2*`}])
-- if (n_1'*{n_1' <- `n_1'*`} = n_1*{n_1 <- `n_1*`} ++ [n'])
Whereas if we comment out the var declaration, it's elaborated into:
;; juxt.spectec:3.1-3.19
def $f(nat*) : nat
;; juxt.spectec:4.1-6.24
def $f{`n*` : nat*, n' : nat, `n_1'*` : nat*, `n_2*` : nat*, `n_1*` : nat*}(n*{n <- `n*`}) = n'
-- if (n*{n <- `n*`} = n_1'*{n_1' <- `n_1'*`} ++ n_2*{n_2 <- `n_2*`})
-- if (n_1'*{n_1' <- `n_1'*`} = n_1*{n_1 <- `n_1*`} ++ [n'])
The variable declaration doesn't change the result of the type inference, but the ILs have totally different semantics.
In the following sample code,
With the
vardeclaration, it's elaborated into:Whereas if we comment out the
vardeclaration, it's elaborated into:The variable declaration doesn't change the result of the type inference, but the ILs have totally different semantics.