Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate and sort error codes #15876

Merged
merged 28 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1dc6018
Deduplicate and sort error codes
Happypig375 Aug 27, 2023
11c9fa5
Update test
Happypig375 Aug 27, 2023
5c4f924
3570 -> 3573
Happypig375 Aug 27, 2023
b7b29ec
1503 -> 1003
Happypig375 Aug 27, 2023
b111c7c
3570 -> 3573
Happypig375 Aug 27, 2023
447e14c
3217 -> 999
Happypig375 Aug 28, 2023
00faa3b
Update output.1000.stderr.bsl
Happypig375 Aug 28, 2023
a22e2f3
Update output.200.stderr.bsl
Happypig375 Aug 28, 2023
5b86d77
Update output.47.stderr.bsl
Happypig375 Aug 28, 2023
32f356c
Update output.multiemit.stderr.bsl
Happypig375 Aug 28, 2023
f791369
Update output.off.stderr.bsl
Happypig375 Aug 28, 2023
e6716d5
Update output.quiet.stderr.bsl
Happypig375 Aug 28, 2023
0990216
Update output.stderr.bsl
Happypig375 Aug 28, 2023
d1ca738
Update output.stderr.bsl
Happypig375 Aug 28, 2023
9678094
Update output.off.stderr.bsl
Happypig375 Aug 28, 2023
a001a7d
Update output.multiemit.stderr.bsl
Happypig375 Aug 28, 2023
1aae03f
Update output.47.stderr.bsl
Happypig375 Aug 28, 2023
a665ae3
Update output.200.stderr.bsl
Happypig375 Aug 28, 2023
5d007eb
Update output.1000.stderr.bsl
Happypig375 Aug 28, 2023
9368513
Update FSComp.txt
Happypig375 Aug 28, 2023
1ec0750
Update FSComp.txt
Happypig375 Aug 28, 2023
1d522b1
Update pdb04.fs
Happypig375 Aug 28, 2023
6410500
Update output.quiet.stderr.bsl
Happypig375 Aug 28, 2023
585a0c0
Merge branch 'main' into patch-18
Happypig375 Aug 28, 2023
fede209
Add a error code sorting check
Happypig375 Aug 28, 2023
ee5281e
Fix wording
Happypig375 Aug 28, 2023
e0bef8f
Update the script
Happypig375 Aug 28, 2023
07220fd
Merge branch 'main' into patch-18
Happypig375 Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D58BFE8B-7C85-4D3B-B5F3-9A7BB90FF1EE}"
ProjectSection(SolutionItems) = preProject
src\Compiler\FSComp.txt = src\Compiler\FSComp.txt
src\Compiler\FSCompCheck.fsx = src\Compiler\FSCompCheck.fsx
EndProjectSection
EndProject
Global
Expand Down
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ stages:
continueOnError: true
condition: not(succeeded())

# Check code formatting
# Check FSComp.txt error code sorting and code formatting
- job: CheckCodeFormatting
pool:
vmImage: $(UbuntuMachineQueueName)
Expand All @@ -270,6 +270,10 @@ stages:
env:
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
displayName: Install tools
- script: dotnet fsi src/Compiler/FSCompCheck.fsx
env:
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
displayName: Check error code sorting in src/Compiler/FSComp.txt
psfinaki marked this conversation as resolved.
Show resolved Hide resolved
- script: dotnet fantomas . -r --check
env:
DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1
Expand Down
40 changes: 20 additions & 20 deletions src/Compiler/FSComp.txt

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/Compiler/FSCompCheck.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
let digits = set { '0' .. '9' }

let rec intStringEndIndex i s =
if i >= String.length s then
String.length s - 1
elif Set.contains s[i] digits then
intStringEndIndex (i + 1) s
else
i - 1

__SOURCE_DIRECTORY__ + "/FSComp.txt"
|> System.IO.File.ReadAllLines
|> Seq.fold
(fun counters line ->
let line = line.TrimStart [| ' '; '#' |]
let intStringEndIndex = intStringEndIndex 0 line

if intStringEndIndex >= 0 then // Line starts with an integer (error code)
let errorCode = line[..intStringEndIndex] |> int

match counters with
| [] -> [ errorCode ] // Initialise a counter
| head :: tail when errorCode >= head -> errorCode :: tail // Increment current counter
psfinaki marked this conversation as resolved.
Show resolved Hide resolved
| _ -> errorCode :: counters // Start a new counter
else
counters)
[]
|> function
| [] -> failwith "FSComp.txt contained no error codes but expected at least one"
| [ _finalErrorCode ] -> () // Expected: One counter counted to the end
| _finalErrorCode :: counters ->
failwith $"Error codes not sorted in FSComp.txt, break(s) happened after {List.rev counters}"
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ let ``Static let extension to builtin type`` compilation =
compilation
|> typecheck
|> shouldFail
|> withDiagnostics [Error 3570, Line 4, Col 5, Line 4, Col 51, "Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead."]
|> withDiagnostics [Error 3573, Line 4, Col 5, Line 4, Col 51, "Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead."]

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"QuotationsForStaticLetRecords.fs"|])>]
let ``Static let - quotations support for records`` compilation =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ x |> Seq.iter(fun r ->
let report errorType code message =
match errorType with
| ErrorReportType.Error ->
if code = 3217 then foundCorrectError <- true
if code = 999 then foundCorrectError <- true
else foundWrongError <- true
| ErrorReportType.Warning -> printfn "PackageManagementWarning %d : %s" code message
ResolvingErrorReport (report)
Expand All @@ -839,7 +839,7 @@ x |> Seq.iter(fun r ->
let report errorType code message =
match errorType with
| ErrorReportType.Error ->
if code = 3217 then foundCorrectError <- true
if code = 999 then foundCorrectError <- true
else foundWrongError <- true
| ErrorReportType.Warning -> printfn "PackageManagementWarning %d : %s" code message
ResolvingErrorReport (report)
Expand Down Expand Up @@ -886,7 +886,7 @@ x |> Seq.iter(fun r ->
let report errorType code message =
match errorType with
| ErrorReportType.Error ->
if code = 3217 then foundCorrectError <- true
if code = 999 then foundCorrectError <- true
else foundWrongError <- true
| ErrorReportType.Warning -> printfn "PackageManagementWarning %d : %s" code message
ResolvingErrorReport (report)
Expand Down
10 changes: 5 additions & 5 deletions tests/fsharp/typecheck/sigs/neg46.bsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

neg46.fs(6,8,6,26): typecheck error FS0912: This declaration element is not permitted in an augmentation

neg46.fs(10,8,10,40): typecheck error FS3570: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.
neg46.fs(10,8,10,40): typecheck error FS3573: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.

neg46.fs(14,8,14,26): typecheck error FS3570: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.
neg46.fs(14,8,14,26): typecheck error FS3573: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.

neg46.fs(18,8,19,21): typecheck error FS3570: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.
neg46.fs(18,8,19,21): typecheck error FS3573: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.

neg46.fs(23,8,23,32): typecheck error FS3570: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.
neg46.fs(23,8,23,32): typecheck error FS3573: Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead.

neg46.fs(27,8,27,25): typecheck error FS0912: This declaration element is not permitted in an augmentation

Expand Down Expand Up @@ -37,4 +37,4 @@ neg46.fs(64,8,64,26): typecheck error FS0912: This declaration element is not pe

neg46.fs(68,18,68,36): typecheck error FS0909: All implemented interfaces should be declared on the initial declaration of the type

neg46.fs(73,18,73,36): typecheck error FS0909: All implemented interfaces should be declared on the initial declaration of the type
neg46.fs(73,18,73,36): typecheck error FS0909: All implemented interfaces should be declared on the initial declaration of the type
2 changes: 1 addition & 1 deletion tests/fsharpqa/Source/CompilerOptions/fsc/pdb/pdb04.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #Regression #NoMT #CompilerOptions #NoMono
// Regression test for FSharp1.0:3204 - Compiler throws exception when trying to use option "-g --pdb" on a locked file (or any non-accessible file)
//<Expects id="FS1503" status="error">The pdb output file name cannot match the build output filename use --pdb:filename.pdb</Expects>
//<Expects id="FS1001" status="error">The pdb output file name cannot match the build output filename use --pdb:filename.pdb</Expects>
exit 1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//<Expects status="Error" span="(4,1)" id="FS3216">Package manager key 'unk' was not registered</Expects>
//<Expects status="Error" span="(4,1)" id="FS3217">Processing of a script fragment has stopped because an exception has been raised</Expects>
//<Expects status="Error" span="(4,1)" id="FS0998">Package manager key 'unk' was not registered</Expects>
//<Expects status="Error" span="(4,1)" id="FS0999">Processing of a script fragment has stopped because an exception has been raised</Expects>

#r "unk: blubblub"

Expand Down