From 2c115085982ba19985f2e00ca938370647e38e4b Mon Sep 17 00:00:00 2001 From: Wojciech Baranowski Date: Sun, 7 Apr 2019 19:25:05 +0300 Subject: rename: hadle type signatures with typos When encountering type signatures for unknown names, suggest similar alternatives. This fixes issue #16504 --- testsuite/tests/parser/should_fail/readFail001.stderr | 2 ++ testsuite/tests/rename/should_fail/T16504.hs | 16 ++++++++++++++++ testsuite/tests/rename/should_fail/T16504.stderr | 14 ++++++++++++++ testsuite/tests/rename/should_fail/all.T | 1 + 4 files changed, 33 insertions(+) create mode 100644 testsuite/tests/rename/should_fail/T16504.hs create mode 100644 testsuite/tests/rename/should_fail/T16504.stderr (limited to 'testsuite') diff --git a/testsuite/tests/parser/should_fail/readFail001.stderr b/testsuite/tests/parser/should_fail/readFail001.stderr index 6425d16c49..0b6d4b4d29 100644 --- a/testsuite/tests/parser/should_fail/readFail001.stderr +++ b/testsuite/tests/parser/should_fail/readFail001.stderr @@ -1,6 +1,8 @@ readFail001.hs:25:11: error: The fixity signature for ‘+#’ lacks an accompanying binding + Perhaps you meant ‘+’ (Defined in ‘GHC.Num’) + Perhaps you meant ‘++’ (Defined in ‘GHC.Base’) readFail001.hs:38:32: error: Not in scope: type constructor or class ‘Leaf’ diff --git a/testsuite/tests/rename/should_fail/T16504.hs b/testsuite/tests/rename/should_fail/T16504.hs new file mode 100644 index 0000000000..1bb6a08226 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T16504.hs @@ -0,0 +1,16 @@ +-- Type signature and definition with name typo +module M where + +-- Both in global scope +simpleFuntcion :: Int -> Bool +simpleFunction i = i > 5 + +-- Both in local scope +f x = anotherFunction x + where anotherFunction :: Int -> Bool + anotherFuntcion i = i > 5 + +-- Global signature, local definition +nonexistentFuntcion :: Int -> Bool +g x = nonexistentFunction x + where nonexistentFunction i = i > 5 diff --git a/testsuite/tests/rename/should_fail/T16504.stderr b/testsuite/tests/rename/should_fail/T16504.stderr new file mode 100644 index 0000000000..7bc59bda3e --- /dev/null +++ b/testsuite/tests/rename/should_fail/T16504.stderr @@ -0,0 +1,14 @@ + +T16504.hs:5:1: error: + The type signature for ‘simpleFuntcion’ + lacks an accompanying binding + Perhaps you meant ‘simpleFunction’ (Defined at T16504.hs:6:1) + +T16504.hs:10:9: error: + The type signature for ‘anotherFunction’ + lacks an accompanying binding + Perhaps you meant ‘anotherFuntcion’ (Defined at T16504.hs:11:9) + +T16504.hs:14:1: error: + The type signature for ‘nonexistentFuntcion’ + lacks an accompanying binding diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index 5bfded171f..52a4f45a04 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -148,3 +148,4 @@ test('T16116b', normal, compile_fail, ['']) test('ExplicitForAllRules2', normal, compile_fail, ['']) test('T15957_Fail', normal, compile_fail, ['-Werror -Wall -Wno-missing-signatures']) test('T16385', normal, compile_fail, ['']) +test('T16504', normal, compile_fail, ['']) -- cgit v1.2.1