Fix incorrect ambiguity error on identically-named data constructors
Given multiple in-scope constructors with the same name, say `A`, and a function of type `A -> Int`, say, the compiler reports both a "type `A` is not in scope" and (incorrectly) an ambiguity error. The latter shouldn't be there if `DataKinds` isn't enabled. This issue was recommended to me by @mpickering as a suitable first task, and the fix was also outlined in the original Trac ticket. It involved a simple reordering of the steps taken in `lookup_demoted` in `RnEnv.hs`. The fix is to make the `DataKinds` check happen earlier, ensuring that the ambiguity check doesn't happen at all if we know the constructors couldn't have been promoted. Signed-off-by:Soham Chowdhury <chow.soham@gmail.com> Reviewers: mpickering, austin, bgamari Reviewed By: mpickering, bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13568 Differential Revision: https://phabricator.haskell.org/D3547 (cherry picked from commit 1381c142)
Showing
- compiler/rename/RnEnv.hs 11 additions, 10 deletionscompiler/rename/RnEnv.hs
- testsuite/tests/module/mod122.stderr 3 additions, 1 deletiontestsuite/tests/module/mod122.stderr
- testsuite/tests/module/mod123.stderr 3 additions, 1 deletiontestsuite/tests/module/mod123.stderr
- testsuite/tests/module/mod124.stderr 1 addition, 0 deletionstestsuite/tests/module/mod124.stderr
- testsuite/tests/module/mod127.stderr 1 addition, 0 deletionstestsuite/tests/module/mod127.stderr
- testsuite/tests/module/mod29.stderr 1 addition, 0 deletionstestsuite/tests/module/mod29.stderr
- testsuite/tests/module/mod50.stderr 3 additions, 1 deletiontestsuite/tests/module/mod50.stderr
- testsuite/tests/parser/should_fail/readFail001.stderr 1 addition, 0 deletionstestsuite/tests/parser/should_fail/readFail001.stderr
- testsuite/tests/rename/prog003/rename.prog003.stderr 3 additions, 1 deletiontestsuite/tests/rename/prog003/rename.prog003.stderr
- testsuite/tests/rename/should_fail/T13568.hs 8 additions, 0 deletionstestsuite/tests/rename/should_fail/T13568.hs
- testsuite/tests/rename/should_fail/T13568.stderr 4 additions, 0 deletionstestsuite/tests/rename/should_fail/T13568.stderr
- testsuite/tests/rename/should_fail/T13568a.hs 3 additions, 0 deletionstestsuite/tests/rename/should_fail/T13568a.hs
- testsuite/tests/rename/should_fail/T1595a.stderr 3 additions, 1 deletiontestsuite/tests/rename/should_fail/T1595a.stderr
- testsuite/tests/rename/should_fail/T5745.stderr 3 additions, 1 deletiontestsuite/tests/rename/should_fail/T5745.stderr
- testsuite/tests/rename/should_fail/all.T 1 addition, 0 deletionstestsuite/tests/rename/should_fail/all.T
- testsuite/tests/typecheck/should_fail/T1595.stderr 4 additions, 2 deletionstestsuite/tests/typecheck/should_fail/T1595.stderr
- testsuite/tests/typecheck/should_fail/tcfail048.stderr 3 additions, 1 deletiontestsuite/tests/typecheck/should_fail/tcfail048.stderr
- testsuite/tests/typecheck/should_fail/tcfail053.stderr 3 additions, 1 deletiontestsuite/tests/typecheck/should_fail/tcfail053.stderr
Loading
Please register or sign in to comment