Giter Site home page Giter Site logo

Comments (3)

andreasabel avatar andreasabel commented on September 22, 2024

Apparently, named arguments in pattern lhss are already discarded (silently!) in the parser. The concrete syntax only has one name per lhs argument:

| PatternSyn Range Name [Arg Name] Pattern

PatternSynArgs :: { [Arg Name] }
PatternSynArgs : DomainFreeBindings {% patternSynArgs $1 }

The culprit is then the patternSynArgs function in the parser:
patternSynArgs :: [NamedArg Binder] -> Parser [Arg Name]
patternSynArgs = mapM pSynArg
where
pSynArg x
| let h = getHiding x, h `notElem` [Hidden, NotHidden] =
abort $ prettyShow h ++ " arguments not allowed to pattern synonyms"
| not (isRelevant x) =
abort "Arguments to pattern synonyms must be relevant"
| Just p <- binderPattern (namedArg x) =
abort "Arguments to pattern synonyms cannot be patterns themselves"
| otherwise = return $ fmap (boundName . binderName . namedThing) x

Named arguments were never supported in pattern synonym definitions; the initial implementation for hidden patsyn parameters only has an example for an unnamed hidden parameter: c935600

Agda < 2.6 rejects to parse them (correct behavior), Agda 2.6.0 and up parses them but can't use them (bad behavior). Thus, this is a regression in 2.6.0.

from agda.

andreasabel avatar andreasabel commented on September 22, 2024

Agda also silently discards tactic attributes in pattern definitions:

open import Agda.Builtin.Nat
open import Agda.Builtin.Reflection
open import Agda.Builtin.Unit

nothing : Term  TC ⊤
nothing hole = returnTC _

pattern p {@(tactic nothing) x} = suc x
-- Accepted, but should complain about tactics not being allowed in pattern synonyms

from agda.

andreasabel avatar andreasabel commented on September 22, 2024

It should maybe also not allow erasure annotations in pattern synonyms...

{-# OPTIONS --erasure #-}

open import Agda.Builtin.Nat

pattern p (@0 x) = suc x
-- should be rejected!

pred : Nat  Nat
pred (p x) = x
pred zero  = zero

from agda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.