未验证 提交 b3a5a40a 编写于 作者: F Florian Verdonck 提交者: GitHub

Initial recovery for function types in union case field. (#15583)

* Initial recovery for function types in union case field.

* Add production for named unionCaseField with invalid type.

* Consider entire function type invalid.

* Add unit test for exception case.

* Update xlf files

* Update component test

* Update error message
上级 a93cb3ff
......@@ -1723,4 +1723,5 @@ featureAccessorFunctionShorthand,"underscore dot shorthand for accessor only fun
3577,tcOverrideUsesMultipleArgumentsInsteadOfTuple,"This override takes a tuple instead of multiple arguments. Try to add an additional layer of parentheses at the method definition (e.g. 'member _.Foo((x, y))'), or remove parentheses at the abstract method declaration (e.g. 'abstract member Foo: 'a * 'b -> 'c')."
featureUnmanagedConstraintCsharpInterop,"Interop between C#'s and F#'s unmanaged generic constraint (emit additional modreq)"
3578,chkCopyUpdateSyntaxInAnonRecords,"This expression is an anonymous record, use {{|...|}} instead of {{...}}."
3579,alwaysUseTypedStringInterpolation,"Interpolated string contains untyped identifiers. Adding typed format specifiers is recommended."
\ No newline at end of file
3579,alwaysUseTypedStringInterpolation,"Interpolated string contains untyped identifiers. Adding typed format specifiers is recommended."
3580,tcUnexpectedFunTypeInUnionCaseField,"Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b)."
\ No newline at end of file
......@@ -2783,6 +2783,17 @@ unionCaseReprElement:
{ let xmlDoc = grabXmlDoc(parseState, [], 1)
mkSynAnonField ($1, xmlDoc) }
| ident COLON invalidUseOfAppTypeFunction
{ let xmlDoc = grabXmlDoc(parseState, [], 1)
let mWhole = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc
reportParseErrorAt ($3 : SynType).Range (FSComp.SR.tcUnexpectedFunTypeInUnionCaseField())
mkSynNamedField ($1, $3, xmlDoc, mWhole) }
| invalidUseOfAppTypeFunction
{ let xmlDoc = grabXmlDoc(parseState, [], 1)
reportParseErrorAt ($1 : SynType).Range (FSComp.SR.tcUnexpectedFunTypeInUnionCaseField())
mkSynAnonField ($1, xmlDoc) }
unionCaseRepr:
| braceFieldDeclList
{ errorR(Deprecated(FSComp.SR.parsConsiderUsingSeparateRecordType(), lhs parseState))
......@@ -5777,6 +5788,31 @@ topAppType:
| appType
{ $1, SynArgInfo([], false, None) }
/* Grammar rule meant for recovery scenarios */
/* For example in unionCaseReprElement where function type is not allowed */
invalidUseOfAppTypeFunction:
| appType RARROW invalidUseOfAppTypeFunction
{ let mArrow = rhs parseState 2
let m = unionRanges (rhs2 parseState 1 2) $3.Range
SynType.Fun($1, $3, m, { ArrowRange = mArrow }) }
| appType RARROW recover
{ let mArrow = rhs parseState 2
let ty = SynType.FromParseError(mArrow.EndRange)
let m = rhs2 parseState 1 2
SynType.Fun($1, ty, m, { ArrowRange = mArrow }) }
| appType RARROW RARROW invalidUseOfAppTypeFunction
{ let mArrow1 = rhs parseState 2
let mArrow2 = rhs parseState 3
reportParseErrorAt mArrow2 (FSComp.SR.parsExpectingType ())
let ty = SynType.FromParseError(mArrow2.StartRange)
let m1 = unionRanges $1.Range $4.Range
let m2 = unionRanges mArrow2 $4.Range
SynType.Fun($1, SynType.Fun(ty, $4, m2, { ArrowRange = mArrow2 }), m1, { ArrowRange = mArrow1 }) }
| appType RARROW appType
{ let mArrow = rhs parseState 2
let m = rhs2 parseState 1 3
SynType.Fun($1, $3, m, { ArrowRange = mArrow }) }
/* Any tokens in this grammar must be added to the lex filter rule 'peekAdjacentTypars' */
/* See the F# specification "Lexical analysis of type applications and type parameter definitions" */
typ:
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Neplatný interpolovaný řetězec. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' se obvykle používá jako omezení typu v obecném kódu, například \"T when ISomeInterface&lt;'T&gt;\" nebo \"let f (x: #ISomeInterface&lt;_&gt;)\". Pokyny najdete v https://aka.ms/fsharp-iwsams. Toto upozornění můžete zakázat pomocí #nowarn \"3536\" nebo '--nowarn:3536'.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Ungültige interpolierte Zeichenfolge. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">„{0}“ wird normalerweise als Typeinschränkung im generischen Code verwendet, z. B. \"'T when ISomeInterface&lt;'T&gt;\" oder \"let f (x: #ISomeInterface&lt;_&gt;)\". Anleitungen finden Sie unter https://aka.ms/fsharp-iwsams. Sie können diese Warnung deaktivieren, indem Sie „#nowarn \"3536\"“ or „--nowarn:3536“ verwenden.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Cadena interpolada no válida. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' se usa normalmente como restricción de tipo en código genérico; por ejemplo, \"'T when ISomeInterface&lt;'T&gt;\" o \"let f (x: #ISomeInterface&lt;_&gt;)\". Consulte https://aka.ms/fsharp-iwsams para obtener instrucciones. Puede deshabilitar esta advertencia con "#nowarn \"3536\"" o "--nowarn:3536".</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Chaîne interpolée non valide. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' est généralement utilisée comme contrainte de type dans le code générique, par exemple \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". Consultez https://aka.ms/fsharp-iwsams pour obtenir de l’aide. Vous pouvez désactiver cet avertissement à l’aide de '#nowarn \"3536\"' or '--nowarn:3536'.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">La stringa interpolata non è valida. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' viene in genere usato come vincolo di tipo nel codice generico, ad esempio \"'T when ISomeInterface&lt;'T&gt;\" o \"let f (x: #ISomeInterface&lt;_&gt;)\". Per indicazioni, vedere https://aka.ms/fsharp-iwsams. È possibile disabilitare questo avviso usando '#nowarn \"3536\"' o '--nowarn:3536'.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">補間された文字列が無効です。{0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' は通常、ジェネリック コードの型制約として使用されます (例: \"'T when ISomeInterface&lt;'T&gt;\" または \"let f (x: #ISomeInterface&lt;_&gt;)\")。ガイダンスについては https://aka.ms/fsharp-iwsams を参照してください。この警告は、'#nowarn \"3536\"' または '--nowarn:3536' を使用して無効にできます。</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">잘못된 보간 문자열. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}'은(는) 일반적으로 제네릭 코드에서 형식 제약 조건으로 사용됩니다(예: \"'T when ISomeInterface&lt;'T&gt;\" 또는 \"let f (x: #ISomeInterface&lt;_&gt;)\"). 지침은 https://aka.ms/fsharp-iwsams를 참조하세요. '#nowarn \"3536\"' 또는 '--nowarn:3536'을 사용하여 이 경고를 비활성화할 수 있습니다.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Nieprawidłowy ciąg interpolowany. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">Element „{0}” jest zwykle używany jako ograniczenie typu w kodzie ogólnym, np. \"" T, gdy ISomeInterface&lt;' T&gt;\" lub \"let f (x: #ISomeInterface&lt;_&gt;)\". Aby uzyskać wskazówki, zobacz https://aka.ms/fsharp-iwsams. To ostrzeżenie można wyłączyć, używając polecenia „nowarn \"3536\"" lub "--nowarn:3536”.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Cadeia de caracteres interpolada inválida. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' normalmente é usado como uma restrição de tipo em código genérico, por exemplo, \"'T when ISomeInterface&lt;'T&gt;\" ou \"let f (x: #ISomeInterface&lt;_&gt;)\". Confira https://aka.ms/fsharp-iwsams para obter as diretrizes. Você pode desabilitar este aviso usando '#nowarn \"3536\"' ou '--nowarn:3536'.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Недопустимая интерполированная строка. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">"{0}" обычно используется в качестве ограничения типа в универсальном коде, например \"'T when ISomeInterface&lt;"T&gt;\" или \"let f (x: #ISomeInterface&lt;_&gt;)\". См. руководство на https://aka.ms/fsharp-iwsams. Это предупреждение можно отключить с помощью "#nowarn \"3536\"" или "--nowarn:3536".</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">Geçersiz düz metin arasına kod eklenmiş dize. {0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' normalde genel kodda tür kısıtlaması olarak kullanılır, ör. \"'T when ISomeInterface&lt;'T&gt;\" veya \"let f (x: #ISomeInterface&lt;_&gt;)\". Rehber için bkz. https://aka.ms/fsharp-iwsams. '#nowarn \"3536\"' veya '--nowarn:3536' kullanarak bu uyarıyı devre dışı bırakabilirsiniz.</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">内插字符串无效。{0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">"{0}" 通常用作泛型代码中的类型约束,例如 \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\"。有关指南,请参阅 https://aka.ms/fsharp-iwsams。可以使用 '#nowarn \"3536\"' 或 '--nowarn:3536' 禁用此警告。</target>
......
......@@ -1372,6 +1372,11 @@
<target state="translated">插補字串無效。{0}</target>
<note />
</trans-unit>
<trans-unit id="tcUnexpectedFunTypeInUnionCaseField">
<source>Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</source>
<target state="new">Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -&gt; b into | Case of (a -&gt; b).</target>
<note />
</trans-unit>
<trans-unit id="tcUsingInterfaceWithStaticAbstractMethodAsType">
<source>'{0}' is normally used as a type constraint in generic code, e.g. \"'T when ISomeInterface&lt;'T&gt;\" or \"let f (x: #ISomeInterface&lt;_&gt;)\". See https://aka.ms/fsharp-iwsams for guidance. You can disable this warning by using '#nowarn \"3536\"' or '--nowarn:3536'.</source>
<target state="translated">'{0}' 通常做為一般程式碼中的類型限制式,例如 \"'T when ISomeInterface&lt;'T&gt;\" 或 \"let f (x: #ISomeInterface&lt;_&gt;)\"。請參閱 https://aka.ms/fsharp-iwsams 以尋求指引。您可以使用 '#nowarn \"3536\"' 或 '--nowarn:3536' 來停用此警告。</target>
......
......@@ -233,6 +233,7 @@
<Compile Include="TypeChecks\Graph\TypedTreeGraph.fs" />
<Compile Include="TypeChecks\Graph\GraphProcessingTests.fs" />
<Compile Include="TypeChecks\TyparNameTests.fs" />
<Compile Include="TypeChecks\CheckTypeTests.fs" />
<Compile Include="CompilerOptions\fsc\checked\checked.fs" />
<Compile Include="CompilerOptions\fsc\cliversion.fs" />
<Compile Include="CompilerOptions\fsc\codepage\codepage.fs" />
......
module TypeChecks.CheckTypeTests
open Xunit
open FSharp.Test.Compiler
[<Fact>]
let ``Union case with function type`` () =
FSharp """
namespace Foo
type Bar = | Bar of int -> int
type Other = int
"""
|> typecheck
|> withSingleDiagnostic (Error 3580, Line 4, Col 21, Line 4, Col 31, "Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b).")
namespace Foo
exception Bar of int -> int
exception Other of int
ImplFile
(ParsedImplFileInput
("/root/Exception/Recover Function Type 01.fs", false,
QualifiedNameOfFile Recover Function Type 01, [], [],
[SynModuleOrNamespace
([Foo], false, DeclaredNamespace,
[Exception
(SynExceptionDefn
(SynExceptionDefnRepr
([],
SynUnionCase
([], SynIdent (Bar, None),
Fields
[SynField
([], false, None,
Fun
(LongIdent (SynLongIdent ([int], [], [None])),
LongIdent (SynLongIdent ([int], [], [None])),
(3,17--3,27), { ArrowRange = (3,21--3,23) }),
false,
PreXmlDoc ((3,17), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,17--3,27), { LeadingKeyword = None })],
PreXmlDocEmpty, None, (3,10--3,27), { BarRange = None }),
None, PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,0--3,27)), None, [], (3,0--3,27)), (3,0--3,27));
Exception
(SynExceptionDefn
(SynExceptionDefnRepr
([],
SynUnionCase
([], SynIdent (Other, None),
Fields
[SynField
([], false, None,
LongIdent (SynLongIdent ([int], [], [None])), false,
PreXmlDoc ((4,19), FSharp.Compiler.Xml.XmlDocCollector),
None, (4,19--4,22), { LeadingKeyword = None })],
PreXmlDocEmpty, None, (4,10--4,22), { BarRange = None }),
None, PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector),
None, (4,0--4,22)), None, [], (4,0--4,22)), (4,0--4,22))],
PreXmlDocEmpty, [], None, (1,0--4,22),
{ LeadingKeyword = Namespace (1,0--1,9) })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
(3,17)-(3,27) parse error Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b).
namespace Foo
type Bar = | Bar of int -> int
type Other = int
ImplFile
(ParsedImplFileInput
("/root/UnionCase/Recover Function Type 01.fs", false,
QualifiedNameOfFile Recover Function Type 01, [], [],
[SynModuleOrNamespace
([Foo], false, DeclaredNamespace,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [Bar],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,8)),
Simple
(Union
(None,
[SynUnionCase
([], SynIdent (Bar, None),
Fields
[SynField
([], false, None,
Fun
(LongIdent
(SynLongIdent ([int], [], [None])),
LongIdent
(SynLongIdent ([int], [], [None])),
(3,20--3,30), { ArrowRange = (3,24--3,26) }),
false,
PreXmlDoc ((3,20), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,20--3,30), { LeadingKeyword = None })],
PreXmlDoc ((3,11), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,13--3,30), { BarRange = Some (3,11--3,12) })],
(3,11--3,30)), (3,11--3,30)), [], None, (3,5--3,30),
{ LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,9--3,10)
WithKeyword = None })], (3,0--3,30));
Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [Other],
PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (4,5--4,10)),
Simple
(TypeAbbrev
(Ok, LongIdent (SynLongIdent ([int], [], [None])),
(4,13--4,16)), (4,13--4,16)), [], None, (4,5--4,16),
{ LeadingKeyword = Type (4,0--4,4)
EqualsRange = Some (4,11--4,12)
WithKeyword = None })], (4,0--4,16))], PreXmlDocEmpty, [],
None, (1,0--4,16), { LeadingKeyword = Namespace (1,0--1,9) })],
(true, true), { ConditionalDirectives = []
CodeComments = [] }, set []))
(3,20)-(3,30) parse error Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b).
namespace Foo
type B = | A of x: int -> int
type Other = int
ImplFile
(ParsedImplFileInput
("/root/UnionCase/Recover Function Type 02.fs", false,
QualifiedNameOfFile Recover Function Type 02, [], [],
[SynModuleOrNamespace
([Foo], false, DeclaredNamespace,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [B],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,6)),
Simple
(Union
(None,
[SynUnionCase
([], SynIdent (A, None),
Fields
[SynField
([], false, Some x,
Fun
(LongIdent
(SynLongIdent ([int], [], [None])),
LongIdent
(SynLongIdent ([int], [], [None])),
(3,19--3,29), { ArrowRange = (3,23--3,25) }),
false,
PreXmlDoc ((3,16), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,16--3,29), { LeadingKeyword = None })],
PreXmlDoc ((3,9), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,11--3,29), { BarRange = Some (3,9--3,10) })],
(3,9--3,29)), (3,9--3,29)), [], None, (3,5--3,29),
{ LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,7--3,8)
WithKeyword = None })], (3,0--3,29));
Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [Other],
PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (4,5--4,10)),
Simple
(TypeAbbrev
(Ok, LongIdent (SynLongIdent ([int], [], [None])),
(4,13--4,16)), (4,13--4,16)), [], None, (4,5--4,16),
{ LeadingKeyword = Type (4,0--4,4)
EqualsRange = Some (4,11--4,12)
WithKeyword = None })], (4,0--4,16))], PreXmlDocEmpty, [],
None, (1,0--4,16), { LeadingKeyword = Namespace (1,0--1,9) })],
(true, true), { ConditionalDirectives = []
CodeComments = [] }, set []))
(3,19)-(3,29) parse error Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b).
namespace Foo
type B = | A of int -> int -> int
type Other = int
ImplFile
(ParsedImplFileInput
("/root/UnionCase/Recover Function Type 03.fs", false,
QualifiedNameOfFile Recover Function Type 03, [], [],
[SynModuleOrNamespace
([Foo], false, DeclaredNamespace,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [B],
PreXmlDoc ((3,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (3,5--3,6)),
Simple
(Union
(None,
[SynUnionCase
([], SynIdent (A, None),
Fields
[SynField
([], false, None,
Fun
(LongIdent
(SynLongIdent ([int], [], [None])),
Fun
(LongIdent
(SynLongIdent ([int], [], [None])),
LongIdent
(SynLongIdent ([int], [], [None])),
(3,23--3,33),
{ ArrowRange = (3,27--3,29) }),
(3,16--3,33), { ArrowRange = (3,20--3,22) }),
false,
PreXmlDoc ((3,16), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,16--3,33), { LeadingKeyword = None })],
PreXmlDoc ((3,9), FSharp.Compiler.Xml.XmlDocCollector),
None, (3,11--3,33), { BarRange = Some (3,9--3,10) })],
(3,9--3,33)), (3,9--3,33)), [], None, (3,5--3,33),
{ LeadingKeyword = Type (3,0--3,4)
EqualsRange = Some (3,7--3,8)
WithKeyword = None })], (3,0--3,33));
Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [Other],
PreXmlDoc ((4,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (4,5--4,10)),
Simple
(TypeAbbrev
(Ok, LongIdent (SynLongIdent ([int], [], [None])),
(4,13--4,16)), (4,13--4,16)), [], None, (4,5--4,16),
{ LeadingKeyword = Type (4,0--4,4)
EqualsRange = Some (4,11--4,12)
WithKeyword = None })], (4,0--4,16))], PreXmlDocEmpty, [],
None, (1,0--4,16), { LeadingKeyword = Namespace (1,0--1,9) })],
(true, true), { ConditionalDirectives = []
CodeComments = [] }, set []))
(3,16)-(3,33) parse error Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b).
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册