diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 104d1df5eac..6aade43c55f 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -8262,8 +8262,9 @@ and TcUnionCaseOrExnCaseOrActivePatternResultItemThen (cenv: cenv) overallTy env // first: put all positional arguments let mutable currentIndex = 0 for arg in unnamedArgs do - fittedArgs[currentIndex] <- arg - currentIndex <- currentIndex + 1 + if currentIndex < fittedArgs.Length then + fittedArgs[currentIndex] <- arg + currentIndex <- currentIndex + 1 let SEEN_NAMED_ARGUMENT = -1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_UnionConstructorBadFieldName.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_UnionConstructorBadFieldName.fs index f9ebb74b26f..01a238ecd76 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_UnionConstructorBadFieldName.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/E_UnionConstructorBadFieldName.fs @@ -14,4 +14,6 @@ match y with | Case1(V3 = "") -> () | _ -> () -let (Case1(V4 = z)) = y \ No newline at end of file +let (Case1(V4 = z)) = y + +let z a = Some ("", "", a = "") \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs index b4c14f7b201..bd0382befeb 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/UnionTypes/UnionTypes.fs @@ -261,6 +261,7 @@ module UnionTypes = (Error 3174, Line 14, Col 9, Line 14, Col 11, "The union case 'Case1' does not have a field named 'V3'.") (Warning 26, Line 15, Col 3, Line 15, Col 10, "This rule will never be matched") (Error 3174, Line 17, Col 12, Line 17, Col 14, "The union case 'Case1' does not have a field named 'V4'.") + (Error 3174, Line 19, Col 25, Line 19, Col 26, "The union case 'Some' does not have a field named 'a'.") ] //SOURCE=E_UnionFieldConflictingName.fs SCFLAGS="--test:ErrorRanges" # E_UnionFieldConflictingName.fs