Skip to content

[spectec] Ambiguous expression juxtaposition #2159

@zilinc

Description

@zilinc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions