Opened 7 months ago

Closed 7 months ago

#13470 closed bug (fixed)

Pattern synonyms bind variables out of scope

Reported by: Iceland_jack Owned by: mpickering
Priority: normal Milestone: 8.2.1
Component: Compiler Version: 8.0.1
Keywords: PatternSynonyms Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC accepts invalid program Test Case: patsyn/should_fail/T13470
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3377
Wiki Page:

Description

Wasn't sure what to call this ticket:

{-# Language PatternSynonyms #-}

pattern XInstrProxy :: (Bool -> Bool) -> a
pattern XInstrProxy not <- _

This works fine, is it intended? It came as some surprise to me when I was renaming type variables only to find it still working even though I hadn't changed the variable in the ViewPattern

import Data.Tagged

pattern XInstrProxy proxy <- ((\(Proxy::Proxy descr) -> Proxy::Proxy (XInstr descr)) -> ty) 

Change History (8)

comment:1 Changed 7 months ago by dfeuer

Type of failure: None/UnknownGHC accepts invalid program

comment:2 Changed 7 months ago by mpickering

Owner: set to mpickering

comment:3 Changed 7 months ago by mpickering

Differential Rev(s): Phab:D3377
Status: newpatch

comment:4 Changed 7 months ago by bgamari

Milestone: 8.2.1
Status: patchmerge

comment:5 Changed 7 months ago by bgamari

Owner: mpickering deleted
Status: mergenew

comment:6 Changed 7 months ago by bgamari

Owner: set to mpickering

comment:7 Changed 7 months ago by Matthew Pickering <matthewtpickering@…>

In d819e41/ghc:

Only use locally bound variables in pattern synonym declarations

Summary:
We were using the unconstrainted `lookupOccRn` function which looked up
any variable in scope. Instead we only want to consider variables brought into
scope by renaming the pattern on the RHS.

A few more changes to make reporting of unbound names suggest the correct
things.

Fixes #13470

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3377

comment:8 Changed 7 months ago by bgamari

Resolution: fixed
Status: newclosed
Test Case: patsyn/should_fail/T13470

This is fixed by comment:7.

Note: See TracTickets for help on using tickets.