Skip to content

[WIP] Improve error reporting: Missing = on type declaration #6603

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
msbuild.binlog
/fcs/FSharp.Compiler.Service.netstandard/*.fs
/fcs/FSharp.Compiler.Service.netstandard/*.fsi
.idea/
1 change: 1 addition & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1458,3 +1458,4 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
3245,tcCopyAndUpdateNeedsRecordType,"The input to a copy-and-update expression that creates an anonymous record must be either an anonymous record or a record"
3300,chkInvalidFunctionParameterType,"The parameter '%s' has an invalid type '%s'. This is not permitted by the rules of Common IL."
3301,chkInvalidFunctionReturnType,"The function or method has an invalid return type '%s'. This is not permitted by the rules of Common IL."
3302,parsEqualsMissingInTypeDefinition,"Unexpected symbol '{' in type definition. Did you forget to use the = operator?"
10 changes: 8 additions & 2 deletions src/fsharp/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,10 @@ tyconDefn:
| typeNameInfo
{ TypeDefn($1,SynTypeDefnRepr.Simple(SynTypeDefnSimpleRepr.None($1.Range),$1.Range),[],$1.Range) }

| typeNameInfo EQUALS tyconDefnRhsBlock
{ let nameRange = rhs parseState 1
| typeNameInfo opt_EQUALS tyconDefnRhsBlock
{
if Option.isNone $2 then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsEqualsMissingInTypeDefinition())
let nameRange = rhs parseState 1
let (tcDefRepr:SynTypeDefnRepr),members = $3 nameRange
let declRange = unionRanges (rhs parseState 1) tcDefRepr.Range
let mWhole = (declRange, members) ||> unionRangeWithListBy (fun (mem:SynMemberDefn) -> mem.Range)
Expand Down Expand Up @@ -4935,6 +4937,10 @@ deprecated_opt_equals:
| EQUALS { deprecatedWithError (FSComp.SR.parsNoEqualShouldFollowNamespace()) (lhs parseState); () }
| /* EMPTY */ { }

opt_EQUALS:
| EQUALS { }
| /* EMPTY */ { }

opt_OBLOCKSEP:
| OBLOCKSEP { }
| /* EMPTY */ { }
Expand Down