Skip to content

Commit

Permalink
Bugfix - 'static meme x = x' should fail (#16345)
Browse files Browse the repository at this point in the history
* Make 'static meme' fail as it should

* New attempt

* Change error message

* Update tests/service/SyntaxTreeTests.fs

Co-authored-by: Adam Boniecki <[email protected]>

---------

Co-authored-by: Adam Boniecki <[email protected]>
  • Loading branch information
T-Gro and abonie authored Nov 30, 2023
1 parent 0368d7d commit fb767e9
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1735,4 +1735,5 @@ featureReuseSameFieldsInStructUnions,"Share underlying fields in a [<Struct>] di
3855,tcNoStaticMemberFoundForOverride,"No static abstract member was found that corresponds to this override"
3859,tcNoStaticPropertyFoundForOverride,"No static abstract property was found that corresponds to this override"
3860,chkStaticMembersOnObjectExpressions,"Object expressions cannot implement interfaces with static abstract members or declare static members."
3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions."
3861,chkTailCallAttrOnNonRec,"The TailCall attribute should only be applied to recursive functions."
3862,parsStaticMemberImcompleteSyntax,"Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration."
3 changes: 3 additions & 0 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -1988,6 +1988,9 @@ classDefnMember:
if Option.isSome $2 then
errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2))
let flags = $3
match flags with
| _, SynLeadingKeyword.Static(mStatic) -> errorR (Error (FSComp.SR.parsStaticMemberImcompleteSyntax (), mStatic))
| _ -> ()
$4 $2 flags $1 rangeStart }

| opt_attributes opt_access memberFlags recover
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/service/SyntaxTreeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ let ParseFile fileName =
let equals = expected = actual
let testUpdateBSLEnv = System.Environment.GetEnvironmentVariable("TEST_UPDATE_BSL")

if not (isNull testUpdateBSLEnv) && testUpdateBSLEnv.Trim() = "1" then
if not (isNull testUpdateBSLEnv) && testUpdateBSLEnv.Trim() = "1" && not equals then
File.WriteAllText(bslPath, actual)
elif not equals then
File.WriteAllText(actualPath, actual)
Expand Down
2 changes: 2 additions & 0 deletions tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type Seq =
static meme average (x: int seq) = x
62 changes: 62 additions & 0 deletions tests/service/data/SyntaxTree/Member/MemberMispelledToMeme.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ImplFile
(ParsedImplFileInput
("/root/Member/MemberMispelledToMeme.fs", false,
QualifiedNameOfFile MemberMispelledToMeme, [], [],
[SynModuleOrNamespace
([MemberMispelledToMeme], false, AnonModule,
[Types
([SynTypeDefn
(SynComponentInfo
([], None, [], [Seq],
PreXmlDoc ((1,0), FSharp.Compiler.Xml.XmlDocCollector),
false, None, (1,5--1,8)),
ObjectModel
(Unspecified,
[Member
(SynBinding
(None, Normal, false, false, [],
PreXmlDoc ((2,3), FSharp.Compiler.Xml.XmlDocCollector),
SynValData
(Some { IsInstance = false
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
MemberKind = Member },
SynValInfo
([[SynArgInfo ([], false, Some average)];
[SynArgInfo ([], false, Some x)]],
SynArgInfo ([], false, None)), None),
LongIdent
(SynLongIdent ([meme], [], [None]), None, None,
Pats
[Named
(SynIdent (average, None), false, None,
(2,15--2,22));
Paren
(Typed
(Named
(SynIdent (x, None), false, None,
(2,24--2,25)),
App
(LongIdent
(SynLongIdent ([seq], [], [None])),
None,
[LongIdent
(SynLongIdent ([int], [], [None]))],
[], None, true, (2,27--2,34)),
(2,24--2,34)), (2,23--2,35))], None,
(2,10--2,35)), None, Ident x, (2,10--2,35),
NoneAtInvisible,
{ LeadingKeyword = Static (2,3--2,9)
InlineKeyword = None
EqualsRange = Some (2,36--2,37) }), (2,3--2,39))],
(2,3--2,39)), [], None, (1,5--2,39),
{ LeadingKeyword = Type (1,0--1,4)
EqualsRange = Some (1,9--1,10)
WithKeyword = None })], (1,0--2,39))], PreXmlDocEmpty, [],
None, (1,0--2,39), { LeadingKeyword = None })], (true, true),
{ ConditionalDirectives = []
CodeComments = [] }, set []))

(2,3)-(2,9) parse error Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration.

0 comments on commit fb767e9

Please sign in to comment.