From 2ac6f915884116918b9b90b4140c7208bac41efb Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 26 Nov 2016 17:07:55 +0100 Subject: [PATCH 1/7] Try to reproduce #461 --- tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs | 7 +++++++ tests/fsharpqa/Source/Warnings/env.lst | 1 + 2 files changed, 8 insertions(+) create mode 100644 tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs diff --git a/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs b/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs new file mode 100644 index 00000000000..b36875472ad --- /dev/null +++ b/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs @@ -0,0 +1,7 @@ +// #Warnings +//This expression was expected to have type + +namespace MyNamespace1 + +module MyModule1 = + let irrelevant = 10 \ No newline at end of file diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst index 5fb27f22b53..1fc205b11d4 100644 --- a/tests/fsharpqa/Source/Warnings/env.lst +++ b/tests/fsharpqa/Source/Warnings/env.lst @@ -7,6 +7,7 @@ SOURCE=InvalidRecord.fs # InvalidRecord.fs SOURCE=CommaInRecCtor.fs # CommaInRecCtor.fs SOURCE=ValidCommaInRecCtor.fs # ValidCommaInRecCtor.fs + SOURCE=FS0988AtEndOfFile.fs # FS0988AtEndOfFile.fs SOURCE=WrongArity.fs # WrongArity.fs SOURCE=AccessOfTypeAbbreviation.fs # AccessOfTypeAbbreviation.fs SOURCE=AccessOfTypeAbbreviation2.fs # AccessOfTypeAbbreviation2.fs From fb74c576620ff35c2f1eef4fa5a2b44daef4769b Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 26 Nov 2016 17:24:11 +0100 Subject: [PATCH 2/7] Extract namespaces and put FS0988 at end of file - fixes #461 --- src/fsharp/CompileOps.fs | 2 ++ tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 5d862a8960e..67ff3445078 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -3146,11 +3146,13 @@ let ComputeQualifiedNameOfFileFromUniquePath (m, p: string list) = QualifiedName let QualFileNameOfSpecs filename specs = match specs with | [SynModuleOrNamespaceSig(modname,_,true,_,_,_,_,m)] -> QualFileNameOfModuleName m filename modname + | [SynModuleOrNamespaceSig(_,_,false,_,_,_,_,m)] -> QualFileNameOfFilename m filename | _ -> QualFileNameOfFilename (rangeN filename 1) filename let QualFileNameOfImpls filename specs = match specs with | [SynModuleOrNamespace(modname,_,true,_,_,_,_,m)] -> QualFileNameOfModuleName m filename modname + | [SynModuleOrNamespace(_,_,false,_,_,_,_,m)] -> QualFileNameOfFilename m filename | _ -> QualFileNameOfFilename (rangeN filename 1) filename let PrepandPathToQualFileName x (QualifiedNameOfFile(q)) = ComputeQualifiedNameOfFileFromUniquePath (q.idRange,pathOfLid x@[q.idText]) diff --git a/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs b/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs index b36875472ad..d965f3a5361 100644 --- a/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs +++ b/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs @@ -1,5 +1,5 @@ // #Warnings -//This expression was expected to have type +//Main module of program is empty: nothing will happen when it is run namespace MyNamespace1 From af3d426dd5af85661b6efafe78f04bff7fdf3ed5 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 26 Nov 2016 17:41:55 +0100 Subject: [PATCH 3/7] Don't generate wrong range --- src/fsharp/CompileOps.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 67ff3445078..045921036c1 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -3147,13 +3147,13 @@ let QualFileNameOfSpecs filename specs = match specs with | [SynModuleOrNamespaceSig(modname,_,true,_,_,_,_,m)] -> QualFileNameOfModuleName m filename modname | [SynModuleOrNamespaceSig(_,_,false,_,_,_,_,m)] -> QualFileNameOfFilename m filename - | _ -> QualFileNameOfFilename (rangeN filename 1) filename + | _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename let QualFileNameOfImpls filename specs = match specs with | [SynModuleOrNamespace(modname,_,true,_,_,_,_,m)] -> QualFileNameOfModuleName m filename modname | [SynModuleOrNamespace(_,_,false,_,_,_,_,m)] -> QualFileNameOfFilename m filename - | _ -> QualFileNameOfFilename (rangeN filename 1) filename + | _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename let PrepandPathToQualFileName x (QualifiedNameOfFile(q)) = ComputeQualifiedNameOfFileFromUniquePath (q.idRange,pathOfLid x@[q.idText]) let PrepandPathToImpl x (SynModuleOrNamespace(p,b,c,d,e,f,g,h)) = SynModuleOrNamespace(x@p,b,c,d,e,f,g,h) From 304209d939d8b55ea9234b7446d47fda96297837 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 27 Nov 2016 12:12:14 +0100 Subject: [PATCH 4/7] Fix test --- .../W_NoEntryPointInLastModuleInsideMultipleNamespace.fs | 2 +- .../Source/EntryPoint/W_NoEntryPointModuleInNamespace.fs | 2 +- .../fsharpqa/Source/EntryPoint/W_NoEntryPointTypeInNamespace.fs | 2 +- tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointInLastModuleInsideMultipleNamespace.fs b/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointInLastModuleInsideMultipleNamespace.fs index 32816f8ea7c..886bea8bee9 100644 --- a/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointInLastModuleInsideMultipleNamespace.fs +++ b/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointInLastModuleInsideMultipleNamespace.fs @@ -2,7 +2,7 @@ // Empty program entry point warning // Lack of entry point produces warning with correct source location when compiled to *.exe // when multiple namespaces with multiple modules declared in source file -//Main module of program is empty: nothing will happen when it is run +//Main module of program is empty: nothing will happen when it is run #light namespace MyNamespace1 diff --git a/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointModuleInNamespace.fs b/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointModuleInNamespace.fs index faf53d678e9..ceaaceef2d3 100644 --- a/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointModuleInNamespace.fs +++ b/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointModuleInNamespace.fs @@ -2,7 +2,7 @@ // Empty program entry point warning // Lack of entry point produces warning with correct source location when compiled to *.exe // when single module declared inside namespace -//Main module of program is empty: nothing will happen when it is run +//Main module of program is empty: nothing will happen when it is run #light namespace MyNamespace1 diff --git a/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointTypeInNamespace.fs b/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointTypeInNamespace.fs index 738e43d131e..d83961f2101 100644 --- a/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointTypeInNamespace.fs +++ b/tests/fsharpqa/Source/EntryPoint/W_NoEntryPointTypeInNamespace.fs @@ -2,7 +2,7 @@ // Empty program entry point warning // Lack of entry point produces warning with correct source location when compiled to *.exe // when source file declares type inside namespace -//Main module of program is empty: nothing will happen when it is run +//Main module of program is empty: nothing will happen when it is run #light namespace MyNamespace1 diff --git a/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs b/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs index d965f3a5361..65b959a32fb 100644 --- a/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs +++ b/tests/fsharpqa/Source/Warnings/FS0988AtEndOfFile.fs @@ -1,5 +1,5 @@ // #Warnings -//Main module of program is empty: nothing will happen when it is run +//Main module of program is empty: nothing will happen when it is run namespace MyNamespace1 From d6b281eb38ec6dcc3937bbbeb4393bfdb781dcbe Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 27 Nov 2016 12:24:46 +0100 Subject: [PATCH 5/7] We should never assume there is a pos 80 --- src/fsharp/range.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index 6ea0ae15d8b..18287fd1d99 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -212,7 +212,7 @@ let rangeContainsPos (m1:range) p = let rangeBeforePos (m1:range) p = posGeq p m1.End -let rangeN filename line = mkRange filename (mkPos line 0) (mkPos line 80) +let rangeN filename line = mkRange filename (mkPos line 0) (mkPos line 0) let pos0 = mkPos 1 0 let range0 = rangeN "unknown" 1 let rangeStartup = rangeN "startup" 1 From afe3d9d2610284bb9c76f5bc015b28cf155d2483 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 27 Nov 2016 12:28:01 +0100 Subject: [PATCH 6/7] Fix test --- tests/fsharp/typecheck/sigs/neg10.bsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/fsharp/typecheck/sigs/neg10.bsl b/tests/fsharp/typecheck/sigs/neg10.bsl index ba47d7e2529..e837732a6b0 100644 --- a/tests/fsharp/typecheck/sigs/neg10.bsl +++ b/tests/fsharp/typecheck/sigs/neg10.bsl @@ -257,4 +257,5 @@ neg10.fs(456,24,456,25): typecheck error FS0001: The type 'C' does not support a neg10.fs(457,26,457,27): typecheck error FS0001: The type 'C' does not support a conversion to the type 'decimal' -neg10.fsi(1,1,1,81): typecheck error FS0240: The signature file 'Neg10' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match. +neg10.fsi(1,1,1,1): typecheck error FS0240: The signature file 'Neg10' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match. + From 010231866b8a7fa9115b91f84f91b081a273ee70 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 27 Nov 2016 13:24:33 +0100 Subject: [PATCH 7/7] Fix test --- tests/fsharp/typecheck/sigs/neg10.bsl | 1 - .../SignatureFiles/E_MissingSourceFile01.fsi | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/fsharp/typecheck/sigs/neg10.bsl b/tests/fsharp/typecheck/sigs/neg10.bsl index e837732a6b0..e10e82c5b58 100644 --- a/tests/fsharp/typecheck/sigs/neg10.bsl +++ b/tests/fsharp/typecheck/sigs/neg10.bsl @@ -258,4 +258,3 @@ neg10.fs(456,24,456,25): typecheck error FS0001: The type 'C' does not support a neg10.fs(457,26,457,27): typecheck error FS0001: The type 'C' does not support a conversion to the type 'decimal' neg10.fsi(1,1,1,1): typecheck error FS0240: The signature file 'Neg10' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match. - diff --git a/tests/fsharpqa/Source/Conformance/ImplementationFilesAndSignatureFiles/SignatureFiles/E_MissingSourceFile01.fsi b/tests/fsharpqa/Source/Conformance/ImplementationFilesAndSignatureFiles/SignatureFiles/E_MissingSourceFile01.fsi index 83feb860f5c..f5f53a17593 100644 --- a/tests/fsharpqa/Source/Conformance/ImplementationFilesAndSignatureFiles/SignatureFiles/E_MissingSourceFile01.fsi +++ b/tests/fsharpqa/Source/Conformance/ImplementationFilesAndSignatureFiles/SignatureFiles/E_MissingSourceFile01.fsi @@ -1,7 +1,7 @@ // #Regression #Conformance #SignatureFiles // Test you get an error if you specify an .fsi file but not the corresponding .fs file. -//The signature file 'E_MissingSourceFile01' does not have a corresponding implementation file\. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match +//The signature file 'E_MissingSourceFile01' does not have a corresponding implementation file\. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match namespace FSharp.Testing.MissingSourceFile01