agda / agda

Agda is a dependently typed programming language / interactive theorem prover.

Home Page:https://wiki.portal.chalmers.se/agda/pmwiki.php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Misprinted domain-free parameters with cohesion attribute

andreasabel opened this issue · comments

{-# OPTIONS --cohesion --erasure #-}

import Agda.Builtin.Bool

postulate
  Flat : (@♭ A : Set)  Set

module @0 Bool where
  open module M (@♭ A) (_ : Flat A) = Agda.Builtin.Bool public

This prints the module abstraction as module M @♭ A (_ : Flat A), which does not parse because of missing parenthesis around @♭ A.

Found this bug by reading the code for the printer:

instance Pretty NamedBinding where
pretty (NamedBinding withH x) = prH $
if | Just l <- isLabeled x -> text l <+> "=" <+> pretty xb
| otherwise -> pretty xb
where
xb = namedArg x
bn = binderName xb
prH | withH = prettyRelevance x
. prettyHiding x mparens
. prettyCohesion x
. prettyQuantity x
. prettyTactic bn
| otherwise = id
-- Parentheses are needed when an attribute @... is present
mparens
| noUserQuantity x, Nothing <- bnameTactic bn = id
| otherwise = parens

This code bit-rotted when cohesion was added in 4a45eb9; the noUserQuantity check became insufficient to check whether there are modalities.

The original test case for #3945 had the bad printing already:

when checking that the expression λ @♭ a → flat a has type