Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#12177 closed bug (fixed)

Relevant bindings includes shadowed bindings

Reported by: ezyang Owned by:
Priority: normal Milestone: 8.0.2
Component: Compiler (Type checker) Version: 8.0.1
Keywords: newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T12177
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D2434
Wiki Page:

Description

ezyang@sabre:~$ ghc-8.0 --interactive
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Prelude> \x -> \x -> _

<interactive>:1:13: error:
    • Found hole: _ :: t2
      Where: ‘t2’ is a rigid type variable bound by
               the inferred type of it :: t -> t1 -> t2 at <interactive>:1:1
    • In the expression: _
      In the expression: \ x -> _
      In the expression: \ x -> \ x -> _
    • Relevant bindings include
        x :: t1 (bound at <interactive>:1:8)
        x :: t (bound at <interactive>:1:2)
        it :: t -> t1 -> t2 (bound at <interactive>:1:1)

GHC should not report bindings which are shadowed.

Change History (11)

comment:1 Changed 3 years ago by mpickering

Keywords: newcomer added

comment:2 Changed 2 years ago by sgillespie

Using the above as an example, I presume the output should look like:

<interactive>:1:13: error:
    • Found hole: _ :: t2
      Where: ‘t2’ is a rigid type variable bound by
               the inferred type of it :: t -> t1 -> t2 at <interactive>:1:1
    • In the expression: _
      In the expression: \ x -> _
      In the expression: \ x -> \ x -> _
    • Relevant bindings include
        x :: t1 (bound at <interactive>:1:8)
        it :: t -> t1 -> t2 (bound at <interactive>:1:1)

Fair presumption?

Last edited 2 years ago by sgillespie (previous) (diff)

comment:3 Changed 2 years ago by simonpj

Good point. Can't be hard; we have a lexical environment to hand to check against. Anyone want to have a go?

comment:4 Changed 2 years ago by anniecherkaev

I think I've got it working! I'll work through the contributing a patch guide and try submitting a patch later today or tomorrow!

comment:5 Changed 2 years ago by ezyang

anniecherkaev: That's awesome! I'll be happy to review your patch, keep us posted. Let me know if you have any questions.

comment:6 Changed 2 years ago by anniecherkaev

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

Great, thanks! I just got a patch up on Phabricator.

comment:7 Changed 2 years ago by Edward Z. Yang <ezyang@…>

In 89ae1e8/ghc:

Relevant Bindings no longer reports shadowed bindings (fixes #12176)

Summary: Modified the RelevantBindings method in TcErrors.hs to only search over
non-shadowed bindings.

Test Plan: Wrote 2 simple test cases, verified that it worked with multiple
shadowed bindings, and also non-shadowed bindings.

Reviewers: austin, bgamari, ezyang

Reviewed By: ezyang

Subscribers: ezyang, thomie

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

GHC Trac Issues: #12177

comment:8 Changed 2 years ago by simonpj

Test Case: typecheck/should_fail/T12177

It looks as though Edward committed the patch, so shouldn't the status change to 'merge' or 'fixed' depending on whether we plan to merge this to 8.0?

I've also updated the Testcase: field, which no one seems to do.

Thanks Annie and Edward.

Simon

comment:9 Changed 2 years ago by thomie

Milestone: 8.0.2
Status: patchmerge

comment:10 Changed 2 years ago by bgamari

Resolution: fixed
Status: mergeclosed

comment:11 Changed 2 years ago by bgamari

Note: See TracTickets for help on using tickets.