From 220131b3c88e149f3e6890da46de31d748233b54 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 12 May 2015 15:32:07 +0100 Subject: [PATCH] update tests, change warning to error --- src/fsharp/check.fs | 8 ++------ tests/fsharp/typecheck/sigs/build.bat | 3 +++ tests/fsharp/typecheck/sigs/neg91.fs | 21 --------------------- tests/fsharp/typecheck/sigs/neg93.bsl | 6 ++++++ tests/fsharp/typecheck/sigs/neg93.fs | 23 +++++++++++++++++++++++ 5 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 tests/fsharp/typecheck/sigs/neg93.bsl create mode 100644 tests/fsharp/typecheck/sigs/neg93.fs diff --git a/src/fsharp/check.fs b/src/fsharp/check.fs index c36838bf0b5..383d0599848 100644 --- a/src/fsharp/check.fs +++ b/src/fsharp/check.fs @@ -353,13 +353,9 @@ let CheckType permitByrefs (cenv:cenv) env m ty = let visitTypar (env,tp) = if not (env.boundTypars.ContainsKey tp) then if tp.IsCompilerGenerated then - warning(Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScopeAnon(),m)) + errorR (Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScopeAnon(),m)) else - warning(Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScope(tp.DisplayName),m)) - //match tp.Rigidity with - //| TyparRigidity.Rigid -> warning(Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScope(tp.),m)) - //| _ -> warning(Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScope(mtext),m)) - + errorR (Error(FSComp.SR.checkNotSufficientlyGenericBecauseOfScope(tp.DisplayName),m)) let visitTyconRef tcref = if not permitByrefs && isByrefLikeTyconRef cenv.g tcref then diff --git a/tests/fsharp/typecheck/sigs/build.bat b/tests/fsharp/typecheck/sigs/build.bat index 649b57969ec..4a22c3c3315 100644 --- a/tests/fsharp/typecheck/sigs/build.bat +++ b/tests/fsharp/typecheck/sigs/build.bat @@ -5,6 +5,9 @@ REM Configure the sample, i.e. where to find the F# compiler and C# compiler. call %~d0%~p0..\..\..\config.bat +call ..\..\single-neg-test.bat neg93 +@if ERRORLEVEL 1 goto Error + "%FSC%" --noframework -r:"%FSCOREDLLPATH%" -r:"%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" -r:"%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" -r:"%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll" -r:"%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" -r:"%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Numerics.dll" -a -o:pos21.dll pos21.fs @if ERRORLEVEL 1 goto Error diff --git a/tests/fsharp/typecheck/sigs/neg91.fs b/tests/fsharp/typecheck/sigs/neg91.fs index 1c31425ea7f..052d7e13059 100644 --- a/tests/fsharp/typecheck/sigs/neg91.fs +++ b/tests/fsharp/typecheck/sigs/neg91.fs @@ -54,24 +54,3 @@ module TestExperimentalSet = A.x <- 1 -// See https://github.com/Microsoft/visualfsharp/issues/32 -module Repro1 = - type T1<'TError>(xx:'TError) = - member x.Foo() = T2.Bar(xx) - and T2 = - static member Bar(arg) = 0 - -//let rec f1<'TError>(xx:'TError) = f2(xx) -//and f2(arg) = 0 - -module Repro2 = - type T1<'TError>(thisActuallyHasToBeHere:'TError) = - member x.Foo() = T2.Bar(failwith "!" : option<'TError>) - and T2 = - static member Bar(arg:option<_>) = 0 - -module Repro3 = - - let rec foo< > c = bar c - and bar c = 0 - diff --git a/tests/fsharp/typecheck/sigs/neg93.bsl b/tests/fsharp/typecheck/sigs/neg93.bsl new file mode 100644 index 00000000000..5e2cda732b2 --- /dev/null +++ b/tests/fsharp/typecheck/sigs/neg93.bsl @@ -0,0 +1,6 @@ + +neg93.fs(8,19,8,22): typecheck error FS3186: Type inference caused the type variable TError to escape its scope. Consider adding an explicit type parameter declaration or adjusting your code to be less generic. + +neg93.fs(17,17,17,20): typecheck error FS3186: Type inference caused the type variable TError to escape its scope. Consider adding an explicit type parameter declaration or adjusting your code to be less generic. + +neg93.fs(21,10,21,13): typecheck error FS3187: Type inference caused an inference type variable to escape its scope. Consider adding type annotations to make your code less generic. diff --git a/tests/fsharp/typecheck/sigs/neg93.fs b/tests/fsharp/typecheck/sigs/neg93.fs new file mode 100644 index 00000000000..dcb4f82c461 --- /dev/null +++ b/tests/fsharp/typecheck/sigs/neg93.fs @@ -0,0 +1,23 @@ +namespace Neg93 + +// See https://github.com/Microsoft/visualfsharp/issues/32 +module Repro1 = + type T1<'TError>(xx:'TError) = + member x.Foo() = T2.Bar(xx) + and T2 = + static member Bar(arg) = 0 + +//let rec f1<'TError>(xx:'TError) = f2(xx) +//and f2(arg) = 0 + +module Repro2 = + type T1<'TError>(thisActuallyHasToBeHere:'TError) = + member x.Foo() = T2.Bar(failwith "!" : option<'TError>) + and T2 = + static member Bar(arg:option<_>) = 0 + +module Repro3 = + + let rec foo< > c = bar c + and bar c = 0 +