diff options
author | Merijn Verstraaten <merijn@inconsistent.nl> | 2014-11-21 15:32:38 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-11-21 17:04:57 -0600 |
commit | 2cc854b7133e38c7ad1107057931761782d03594 (patch) | |
tree | 399b3ccdcc7c43dce2e598d1ea42e72ff818000c /testsuite | |
parent | 624a7c5a2eee0c0ba486a45550680052c2c79849 (diff) | |
download | haskell-2cc854b7133e38c7ad1107057931761782d03594.tar.gz |
Add -fdefer-typed-holes flag which defers hole errors to runtime.
Summary:
As proposed by Richard on Trac. This patch adds a new flag -fdefer-typed-holes
and changes the semantics of the -fno-warn-typed-holes flag.
To summarise, by default GHC has typed holes enabled and produces a compile
error when it encounters a typed hole.
When -fdefer-type-errors OR -fdefer-typed-holes is enabled, hole errors are
converted to warnings and result in runtime errors when evaluated.
The warning flag -fwarn-typed-holes is on by default. Without -fdefer-type-errors
or -fdefer-typed-holes this flag is a no-op, since typed holes are an error
under these conditions. If either of the defer flags are enabled (converting
typed hole errors into warnings) the -fno-warn-typed-holes flag disables the
warnings. This means compilation silently succeeds and evaluating a hole will
produce a runtime error.
The rationale behind allowing typed holes warnings to be silenced is that tools
like Syntastic for vim highlight warnings and hole warnings may be undesirable.
Signed-off-by: Merijn Verstraaten <merijn@inconsistent.nl>
Test Plan: validate
Reviewers: austin, simonpj, thomie
Reviewed By: simonpj, thomie
Subscribers: Fuuzetsu, thomie, carter
Differential Revision: https://phabricator.haskell.org/D442
GHC Trac Issues: #9497
Conflicts:
compiler/main/DynFlags.hs
Diffstat (limited to 'testsuite')
19 files changed, 64 insertions, 3 deletions
diff --git a/testsuite/tests/module/mod71.stderr b/testsuite/tests/module/mod71.stderr index f42d17de0c..7cf7e0bf7b 100644 --- a/testsuite/tests/module/mod71.stderr +++ b/testsuite/tests/module/mod71.stderr @@ -1,2 +1,11 @@ -mod71.hs:4:9: Pattern syntax in expression context: _ +mod71.hs:4:9: + Found hole ‘_’ with type: t1 + Where: ‘t1’ is a rigid type variable bound by + the inferred type of f :: (t1 -> a -> t) -> t at mod71.hs:4:1 + Relevant bindings include + x :: t1 -> a -> t (bound at mod71.hs:4:3) + f :: (t1 -> a -> t) -> t (bound at mod71.hs:4:1) + In the first argument of ‘x’, namely ‘_’ + In the expression: x _ 1 + In an equation for ‘f’: f x = x _ 1 diff --git a/testsuite/tests/rename/should_fail/rnfail016.stderr b/testsuite/tests/rename/should_fail/rnfail016.stderr index b24db3cf6a..eeeddfa58c 100644 --- a/testsuite/tests/rename/should_fail/rnfail016.stderr +++ b/testsuite/tests/rename/should_fail/rnfail016.stderr @@ -2,5 +2,3 @@ rnfail016.hs:6:7: Pattern syntax in expression context: x@x rnfail016.hs:7:7: Pattern syntax in expression context: ~x - -rnfail016.hs:8:7: Pattern syntax in expression context: _ diff --git a/testsuite/tests/typecheck/should_compile/T9497a.hs b/testsuite/tests/typecheck/should_compile/T9497a.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T9497a.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_compile/T9497a.stderr b/testsuite/tests/typecheck/should_compile/T9497a.stderr new file mode 100644 index 0000000000..763fbaea33 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T9497a.stderr @@ -0,0 +1,6 @@ + +T9497a.hs:2:8: Warning: + Found hole ‘_main’ with type: IO () + Relevant bindings include main :: IO () (bound at T9497a.hs:2:1) + In the expression: _main + In an equation for ‘main’: main = _main diff --git a/testsuite/tests/typecheck/should_compile/T9497b.hs b/testsuite/tests/typecheck/should_compile/T9497b.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T9497b.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_compile/T9497b.stderr b/testsuite/tests/typecheck/should_compile/T9497b.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T9497b.stderr diff --git a/testsuite/tests/typecheck/should_compile/T9497c.hs b/testsuite/tests/typecheck/should_compile/T9497c.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T9497c.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_compile/T9497c.stderr b/testsuite/tests/typecheck/should_compile/T9497c.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T9497c.stderr diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 8acfa4aa53..b16ff4309d 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -428,3 +428,6 @@ test('T9404b', normal, compile, ['']) test('T7220', normal, compile, ['']) test('T7220a', normal, compile_fail, ['']) test('T9151', normal, compile, ['']) +test('T9497a', normal, compile, ['-fdefer-typed-holes']) +test('T9497b', normal, compile, ['-fdefer-typed-holes -fno-warn-typed-holes']) +test('T9497c', normal, compile, ['-fdefer-type-errors -fno-warn-typed-holes']) diff --git a/testsuite/tests/typecheck/should_fail/T9497d.hs b/testsuite/tests/typecheck/should_fail/T9497d.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T9497d.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_fail/T9497d.stderr b/testsuite/tests/typecheck/should_fail/T9497d.stderr new file mode 100644 index 0000000000..4f18ce9497 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T9497d.stderr @@ -0,0 +1,6 @@ + +T9497d.hs:2:8: + Found hole ‘_main’ with type: IO () + Relevant bindings include main :: IO () (bound at T9497d.hs:2:1) + In the expression: _main + In an equation for ‘main’: main = _main diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 96396d27c4..81ea3d25b9 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -343,3 +343,4 @@ test('T9774', normal, compile_fail, ['']) test('T9318', normal, compile_fail, ['']) test('T9201', normal, compile_fail, ['']) test('T9109', normal, compile_fail, ['']) +test('T9497d', normal, compile_fail, ['-fdefer-type-errors -fno-defer-typed-holes']) diff --git a/testsuite/tests/typecheck/should_run/T9497a-run.hs b/testsuite/tests/typecheck/should_run/T9497a-run.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T9497a-run.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_run/T9497a-run.stderr b/testsuite/tests/typecheck/should_run/T9497a-run.stderr new file mode 100644 index 0000000000..aae24cf396 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T9497a-run.stderr @@ -0,0 +1,7 @@ +T9497a-run: T9497a-run.hs:2:8: + Found hole ‘_main’ with type: IO () + Relevant bindings include + main :: IO () (bound at T9497a-run.hs:2:1) + In the expression: _main + In an equation for ‘main’: main = _main +(deferred type error) diff --git a/testsuite/tests/typecheck/should_run/T9497b-run.hs b/testsuite/tests/typecheck/should_run/T9497b-run.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T9497b-run.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_run/T9497b-run.stderr b/testsuite/tests/typecheck/should_run/T9497b-run.stderr new file mode 100644 index 0000000000..62d858f879 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T9497b-run.stderr @@ -0,0 +1,7 @@ +T9497b-run: T9497b-run.hs:2:8: + Found hole ‘_main’ with type: IO () + Relevant bindings include + main :: IO () (bound at T9497b-run.hs:2:1) + In the expression: _main + In an equation for ‘main’: main = _main +(deferred type error) diff --git a/testsuite/tests/typecheck/should_run/T9497c-run.hs b/testsuite/tests/typecheck/should_run/T9497c-run.hs new file mode 100644 index 0000000000..fa30912352 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T9497c-run.hs @@ -0,0 +1,2 @@ +main :: IO () +main = _main diff --git a/testsuite/tests/typecheck/should_run/T9497c-run.stderr b/testsuite/tests/typecheck/should_run/T9497c-run.stderr new file mode 100644 index 0000000000..be5d9472f7 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T9497c-run.stderr @@ -0,0 +1,7 @@ +T9497c-run: T9497c-run.hs:2:8: + Found hole ‘_main’ with type: IO () + Relevant bindings include + main :: IO () (bound at T9497c-run.hs:2:1) + In the expression: _main + In an equation for ‘main’: main = _main +(deferred type error) diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T index 5da7c8b169..53c97ea1a8 100755 --- a/testsuite/tests/typecheck/should_run/all.T +++ b/testsuite/tests/typecheck/should_run/all.T @@ -112,3 +112,6 @@ test('TcTypeNatSimpleRun', normal, compile_and_run, ['']) test('T8119', normal, ghci_script, ['T8119.script']) test('T8492', normal, compile_and_run, ['']) test('T8739', normal, compile_and_run, ['']) +test('T9497a-run', [exit_code(1)], compile_and_run, ['-fdefer-typed-holes']) +test('T9497b-run', [exit_code(1)], compile_and_run, ['-fdefer-typed-holes -fno-warn-typed-holes']) +test('T9497c-run', [exit_code(1)], compile_and_run, ['-fdefer-type-errors -fno-warn-typed-holes']) |