Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c26a52

Browse files
forkiKevinRansom
authored andcommitted
Report better error for invalid = in for loop (dotnet#1934)
1 parente2da66e commit0c26a52

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

‎src/fsharp/FSComp.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,4 +1332,5 @@ tcTupleStructMismatch,"One tuple type is a struct tuple, the other is a referenc
13321332
3211,DefaultParameterValueNotAppropriateForArgument,"The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'."
13331333
tcGlobalsSystemTypeNotFound,"The system type '%s' was required but no referenced system DLL contained this type"
13341334
3213,typrelMemberHasMultiplePossibleDispatchSlots,"The member '%s' matches multiple overloads of the same method.\nPlease restrict it to one of the following:%s."
1335-
3214,methodIsNotStatic,"Method or object constructor '%s' is not static"
1335+
3214,methodIsNotStatic,"Method or object constructor '%s' is not static"
1336+
3215,parsUnexpectedSymbolEqualsInsteadOfIn,"Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?"

‎src/fsharp/pars.fsy‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3903,9 +3903,12 @@ forLoopBinder:
39033903
($1, arbExpr("forLoopBinder2",(rhs parseState 1).EndRange), false) }
39043904

39053905
forLoopRange:
3906-
| parenPattern EQUALS declExprforLoopDirection declExpr
3906+
| parenPattern EQUALS declExpr forLoopDirection declExpr
39073907
{ idOfPat (rhs parseState 1) $1,$3,$4,$5 }
39083908

3909+
| parenPattern EQUALS rangeSequenceExpr
3910+
{ raiseParseErrorAt (rhs parseState 2) (FSComp.SR.parsUnexpectedSymbolEqualsInsteadOfIn()) }
3911+
39093912
inlineAssemblyExpr:
39103913
| HASH stringOrKeywordString opt_inlineAssemblyTypeArg opt_curriedArgExprs opt_inlineAssemblyReturnTypes HASH
39113914
{ libraryOnlyWarning (lhs parseState)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #Warnings
2+
//<Expects status="Error" id="FS3215">Unexpected symbol '=' in expression. Did you intend to use 'for x in y .. z do' instead?</Expects>
3+
4+
for i=0..100do
5+
()
6+
7+
exit0

‎tests/fsharpqa/Source/Warnings/env.lst‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
SOURCE=TupleInAbstractMethod.fs # TupleInAbstractMethod.fs
77
SOURCE=InvalidRecord.fs # InvalidRecord.fs
88
SOURCE=CommaInRecCtor.fs # CommaInRecCtor.fs
9-
SOURCE=MissingCommaInCtor.fs # MissingCommaInCtor.fs
10-
SOURCE=MissingCtorValue.fs # MissingCtorValue.fs
9+
SOURCE=MissingCommaInCtor.fs # MissingCommaInCtor.fs
10+
SOURCE=MissingCtorValue.fs # MissingCtorValue.fs
1111
SOURCE=ExtraArgumentInCtor.fs # ExtraArgumentInCtor.fs
1212
SOURCE=ExtraArgumentInCtor2.fs # ExtraArgumentInCtor2.fs
1313
SOURCE=ValidCommaInRecCtor.fs # ValidCommaInRecCtor.fs
@@ -21,6 +21,7 @@
2121
SOURCE=AccessOfTypeAbbreviation4.fs # AccessOfTypeAbbreviation4.fs
2222
SOURCE=AccessOfTypeAbbreviation5.fs # AccessOfTypeAbbreviation5.fs
2323
SOURCE=AccessOfTypeAbbreviation6.fs # AccessOfTypeAbbreviation6.fs
24+
SOURCE=EqualsInsteadOfInInForLoop.fs # EqualsInsteadOfInInForLoop.fs
2425
SOURCE=DontWarnExternalFunctionAsUnused.fs SCFLAGS="--warnon:1182 --warnaserror+" # DontWarnExternalFunctionAsUnused.fs
2526
SOURCE=SuggestTypesInModule.fs # SuggestTypesInModule.fs
2627
SOURCE=SuggestGenericType.fs # SuggestGenericType.fs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp