Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,10 @@ module TcRecdUnionAndEnumDeclarations =
Construct.NewUnionCase id rfields recordTy attrs xmlDoc vis

let TcUnionCaseDecls (cenv: cenv) env (parent: ParentRef) (thisTy: TType) (thisTyInst: TypeInst) hasRQAAttribute tpenv unionCases =
let unionCasesR = unionCases |> List.map (TcUnionCaseDecl cenv env parent thisTy thisTyInst tpenv hasRQAAttribute)
let unionCasesR =
unionCases
|> List.filter (fun (SynUnionCase(_, SynIdent(id, _), _, _, _, _, _)) -> id.idText <> "")
|> List.map (TcUnionCaseDecl cenv env parent thisTy thisTyInst tpenv hasRQAAttribute)
unionCasesR |> CheckDuplicates (fun uc -> uc.Id) "union case"

let MakeEnumCaseSpec cenv env parent attrs thisTy caseRange (caseIdent: Ident) (xmldoc: PreXmlDoc) value =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1685,4 +1685,5 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form
3561,chkAutoOpenAttributeInTypeAbbrev,"FSharp.Core.AutoOpenAttribute should not be aliased."
3562,parsUnexpectedEndOfFileElif,"Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'."
3563,lexInvalidIdentifier,"This is not a valid identifier"
3564,parsMissingUnionCaseName,"Missing union case name"
3565,parsExpectingType,"Expecting type"
64 changes: 56 additions & 8 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,14 @@ attrUnionCaseDecl:
let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
Choice2Of2 (SynUnionCase ( $1, $3, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }

| opt_attributes opt_access recover
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
(fun (xmlDoc, mBar) ->
let id = SynIdent(mkSynId mBar.EndRange "", None)
let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
let mDecl = unionRangeWithXmlDoc xmlDoc mBar
Choice2Of2 (SynUnionCase ( $1, id, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }

| opt_attributes opt_access unionCaseName OF unionCaseRepr
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
let mDecl = rhs2 parseState 1 5
Expand All @@ -2395,6 +2403,30 @@ attrUnionCaseDecl:
let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
Choice2Of2 (SynUnionCase ( $1, $3, SynUnionCaseKind.Fields $5, xmlDoc, None, mDecl, trivia))) }

| opt_attributes opt_access OF unionCaseRepr
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
let mOf = rhs parseState 3
let mId = mOf.StartRange
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
let mDecl = rhs2 parseState 1 4
(fun (xmlDoc, mBar) ->
let id = SynIdent(mkSynId mId "", None)
let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
Choice2Of2(SynUnionCase($1, id, SynUnionCaseKind.Fields $4, xmlDoc, None, mDecl, trivia))) }

| opt_attributes opt_access OF recover
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
let mOf = rhs parseState 3
let mId = mOf.StartRange
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
let mDecl = rhs2 parseState 1 3
(fun (xmlDoc, mBar) ->
let id = SynIdent(mkSynId mId "", None)
let trivia: SynUnionCaseTrivia = { BarRange = Some mBar }
let mDecl = unionRangeWithXmlDoc xmlDoc mDecl
Choice2Of2(SynUnionCase($1, id, SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia))) }

| opt_attributes opt_access unionCaseName OF recover
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnionCasesCannotHaveVisibilityDeclarations(), rhs parseState 2))
let mDecl = rhs2 parseState 1 4
Expand Down Expand Up @@ -2453,19 +2485,35 @@ firstUnionCaseDeclOfMany:
| firstUnionCaseDecl opt_OBLOCKSEP
{ $1 }

firstUnionCaseDecl:
| ident OF unionCaseRepr
{ let trivia: SynUnionCaseTrivia = { BarRange = None }
let xmlDoc = grabXmlDoc(parseState, [], 1)
let mDecl = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc
Choice2Of2 (SynUnionCase ( [], SynIdent($1, None), SynUnionCaseKind.Fields $3, xmlDoc, None, mDecl, trivia)) }
firstUnionCaseDecl:
| ident OF unionCaseRepr
{ let trivia: SynUnionCaseTrivia = { BarRange = None }
let xmlDoc = grabXmlDoc (parseState, [], 1)
let mDecl = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc
Choice2Of2(SynUnionCase([], SynIdent($1, None), SynUnionCaseKind.Fields $3, xmlDoc, None, mDecl, trivia)) }

| ident OF recover
{ let trivia: SynUnionCaseTrivia = { BarRange = None }
let xmlDoc = grabXmlDoc (parseState, [], 1)
let mDecl = rhs2 parseState 1 2 |> unionRangeWithXmlDoc xmlDoc
Choice2Of2(SynUnionCase([], SynIdent($1, None), SynUnionCaseKind.Fields [], xmlDoc, None, mDecl, trivia)) }

| OF unionCaseRepr
{ let mOf = rhs parseState 1
let mId = mOf.StartRange
errorR (Error(FSComp.SR.parsMissingUnionCaseName(), mOf))
let id = SynIdent(mkSynId mId "", None)
let trivia: SynUnionCaseTrivia = { BarRange = None }
let xmlDoc = grabXmlDoc (parseState, [], 1)
let mDecl = rhs2 parseState 1 2 |> unionRangeWithXmlDoc xmlDoc
Choice2Of2(SynUnionCase([], id, SynUnionCaseKind.Fields $2, xmlDoc, None, mDecl, trivia)) }

| ident EQUALS atomicExpr opt_OBLOCKSEP
{ let mEquals = rhs parseState 2
let trivia: SynEnumCaseTrivia = { BarRange = None; EqualsRange = mEquals }
let xmlDoc = grabXmlDoc(parseState, [], 1)
let xmlDoc = grabXmlDoc (parseState, [], 1)
let mDecl = rhs2 parseState 1 3 |> unionRangeWithXmlDoc xmlDoc
Choice1Of2 (SynEnumCase ([], SynIdent($1, None), fst $3, xmlDoc, mDecl, trivia)) }
Choice1Of2(SynEnumCase([], SynIdent($1, None), fst $3, xmlDoc, mDecl, trivia)) }

unionCaseReprElements:
| unionCaseReprElement STAR unionCaseReprElements
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Neúplný výraz operátoru (například^b) nebo volání kvalifikovaného typu (příklad: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Tento přístup člena je nejednoznačný. Při vytváření objektu použijte závorky, např. (new SomeType(args)).MemberName'</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Unvollständiger Operatorausdruck (Beispiel: a^b) oder qualifizierter Typaufruf (Beispiel: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Dieser Memberzugriff ist mehrdeutig. Setzen Sie Klammern um die Objekterstellung, z. B. "(new SomeType(args)). MemberName“</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Expresión de operador incompleta (ejemplo, a^b) o invocación de tipo calificada (ejemplo: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Este acceso de miembro es ambiguo. Use paréntesis alrededor de la creación del objeto, por ejemplo, '(nuevo AlgúnTipo(args)).NombreMiembro'</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Expression d’opérateur incomplète (exemple a^b) ou appel de type qualifié (exemple : ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">L’accès à ce membre est ambigu. Utilisez des parenthèses autour de la création de l’objet, par exemple' (New SomeType (args)). MemberName</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Espressione operatore incompleta (ad esempio a^b) o chiamata di tipo qualificato (ad esempio: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">L'accesso ai membri è ambiguo. Utilizzare le parentesi intorno alla creazione oggetto, ad esempio “(New SomeType (args)). MemberName”</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">不完全な演算子式 (例 a^b) または修飾型の呼び出し (例: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">このメンバーへのアクセスはあいまいです。オブジェクト作成の前後にはかっこを使用してください。例: '(new SomeType(args)).MemberName'</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">불완전한 연산자 식(예: a^b) 또는 정규화된 형식 호출(예: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">이 구성원 액세스가 모호합니다. 개체 생성 주위에 괄호를 사용하세요. 예: '(새로운 SomeType(인수)).MemberName'</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Niekompletne wyrażenie operatora (na przykład a^b) lub wywołanie typu kwalifikowanego (przykład: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Dostęp tego elementu członkowskiego jest niejednoznaczny. W celu utworzenia obiektu użyj nawiasów, na przykład „(nowy SomeType(args)).MemberName”</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Expressão de operador incompleta (exemplo a^b) ou invocação de tipo qualificado (exemplo: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Este acesso de membro é ambíguo. Use parênteses em torno da criação do objeto, por exemplo, '(new SomeType(args)).MemberName''.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Неполное выражение оператора (например, a^b) или вызов квалифицированного типа (например, ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Неоднозначный доступ к этому элементу. Заключите операцию создания объекта в круглые скобки, например (new Объект(аргументы)).Элемент</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">Eksik işleç ifadesi (örnek a^b) veya tam tür çağrısı (örnek: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">Bu üye erişimi belirsiz. Lütfen nesne oluşturma etrafında parantez kullanın, örneğin '(yeni SomeType (args)).MemberName’</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">运算符表达式不完整(示例: a^b)或限定类型调用(示例: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">此成员访问权限不明确。请在对象创建周围使用括号,例如 “(new SomeType(args)).MemberName”</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@
<target state="translated">不完整的運算子運算式 (範例 a^b) 或限定類型調用 (範例: ^T.Name)</target>
<note />
</trans-unit>
<trans-unit id="parsMissingUnionCaseName">
<source>Missing union case name</source>
<target state="new">Missing union case name</target>
<note />
</trans-unit>
<trans-unit id="parsNewExprMemberAccess">
<source>This member access is ambiguous. Please use parentheses around the object creation, e.g. '(new SomeType(args)).MemberName'</source>
<target state="translated">此成員存取不明確。請在物件建立前後加上括弧,例如「(new SomeType(args)).MemberName」</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module TypeAbbreviations =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 6, Col 16, Line 6, Col 18, "Unexpected keyword 'of' in type definition")
(Error 3564, Line 6, Col 16, Line 6, Col 18, "Missing union case name")
]

//SOURCE=E_IncorrectRightSide_Quotation.fsx SCFLAGS="--test:ErrorRanges" # E_IncorrectRightSide_Quotation.fsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module UnionTypes =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 8, Col 12, Line 8, Col 13, "Unexpected integer literal in union case. Expected identifier, '(', '(*)' or other token.")
(Error 10, Line 8, Col 12, Line 8, Col 13, "Unexpected integer literal in union case")
]

//SOURCE=E_BeginWithUppercase03.fsx SCFLAGS="--test:ErrorRanges" # E_BeginWithUppercase03.fsx
Expand All @@ -81,7 +81,7 @@ module UnionTypes =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 9, Col 12, Line 9, Col 15, "Unexpected string literal in union case. Expected identifier, '(', '(*)' or other token.")
(Error 10, Line 9, Col 12, Line 9, Col 15, "Unexpected string literal in union case")
]

//SOURCE=E_BeginWithUppercase04.fsx SCFLAGS="--test:ErrorRanges" # E_BeginWithUppercase04.fsx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #Regression #Diagnostics
// Regression test for FSharp1.0:3702
//<Expects id="FS0010" span="(10,5-10,9)" status="error">Incomplete structured construct at or before this point in union case\. Expected identifier, '\(', '\(\*\)' or other token\.$</Expects>
//<Expects id="FS0010" span="(10,5-10,9)" status="error">Incomplete structured construct at or before this point in union case</Expects>
#light

type Stuff = | AnonymousVariableType of string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #Regression #Diagnostics
// Regression test for FSharp1.0:3702
//<Expects status="notin">NONTERM</Expects>
//<Expects id="FS0010" status="error" span="(12,5-12,9)">Incomplete structured construct at or before this point in union case\. Expected identifier, '\(', '\(\*\)' or other token\.$</Expects>
//<Expects id="FS0010" status="error" span="(12,5-12,9)">Incomplete structured construct at or before this point in union case</Expects>



Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// #Regression #NoMT #FSI
// Regression test for FSHARP1.0:5629
//<Expects status="error" span="(4,12)" id="FS0010">Incomplete structured construct at or before this point in union case\. Expected identifier, '\(', '\(\*\)' or other token\.$</Expects>
//<Expects status="error" span="(4,12)" id="FS0010">Incomplete structured construct at or before this point in union case</Expects>
type R = | ;;
exit 1;;
4 changes: 4 additions & 0 deletions tests/service/data/SyntaxTree/UnionCase/Missing name 01.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module

type U =
|
Loading