You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Illegal syntax in an active pattern produces an internal compiler error #5745
Description: A specific kind of incorrect syntax in an active pattern definition causes an internal compiler error rather than a message specific to the error.
Repro Steps: Add the following code:
open System.Text.RegularExpressions
let (|USZipPlus4Code|_|) s =
let m = Regex.Match(s, @"^(\d{5})\-(\d{4})$")
if m.Success then
USZipPlus4Code(x=m.Groups.[1].Value,
y=m.Groups.[2].Value)
|> Some
else
None
Expected: An error along the lines of:
'Active pattern bindings do not support field names.'
exit status 1
/home/runner/main.fs(6,9): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(6,9): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(5,5): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(4,5): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(4,5): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(3,1): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(1,1): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
/home/runner/main.fs(1,1): error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
error FS0193: internal error: The index was outside the range of elements in the list.
Parameter name: index
error FS0073: internal error: The index was outside the range of elements in the list.
Parameter name: index (ArgumentException)
error FS0193: internal error: The index was outside the range of elements in the list.
Parameter name: index
Unhandled Exception:
System.ArgumentException: The index was outside the range of elements in the list.
Parameter name: index
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) <0x40ad6fe0 + 0x00173> in <filename unknown>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger x, System.Exception exn, range m) <0x40ac22e0 + 0x002e7> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: The index was outside the range of elements in the list.
Parameter name: index
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) <0x40ad6fe0 + 0x00173> in <filename unknown>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger x, System.Exception exn, range m) <0x40ac22e0 + 0x002e7> in <filename unknown>:0
So the error message is different, but it's still an internal error.
Activity
cartermp commentedon Oct 8, 2018
From F# 4.0:
So the error message is different, but it's still an internal error.
forki commentedon Oct 9, 2018
would this make more sense? it says UnionCase USZipPlus4Code doesn't have field y.
forki commentedon Oct 9, 2018
I assume we should replace the "UnionCase" with "ActivePattern". But would this be helpful?
Remove one "impossible" error (#5746)