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
2,482 changes: 1,243 additions & 1,239 deletions src/buildfromsource/FSharp.Compiler.Private/FSComp.fs

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/buildfromsource/FSharp.Compiler.Private/FSComp.resx
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,6 @@
<data name="typrelCannotResolveImplicitGenericInstantiation" xml:space="preserve">
<value>The implicit instantiation of a generic construct at or near this point could not be resolved because it could resolve to multiple unrelated types, e.g. '{0}' and '{1}'. Consider using type annotations to resolve the ambiguity</value>
</data>
<data name="typrelCannotResolveAmbiguityInOverloadedOperator" xml:space="preserve">
<value>Could not resolve the ambiguity inherent in the use of the operator '{0}' at or near this program point. Consider using type annotations to resolve the ambiguity.</value>
</data>
<data name="typrelCannotResolveAmbiguityInPrintf" xml:space="preserve">
<value>Could not resolve the ambiguity inherent in the use of a 'printf'-style format string</value>
</data>
Expand Down Expand Up @@ -4306,4 +4303,10 @@
<data name="tcTupleMemberNotNormallyUsed" xml:space="preserve">
<value>This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</value>
</data>
<data name="implicitlyDiscardedInSequenceExpression" xml:space="preserve">
<value>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</value>
</data>
<data name="implicitlyDiscardedSequenceInSequenceExpression" xml:space="preserve">
<value>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
os.Append(System.Environment.NewLine + FSComp.SR.derefInsteadOfNot()) |> ignore
| _ -> os.Append(ErrorFromAddingTypeEquation1E().Format t2 t1 tpcs) |> ignore

| ErrorFromAddingTypeEquation(_, _, _, _, ((ConstraintSolverTypesNotInEqualityRelation (_, _, _, _, _, contextInfo) ) as e), _) when contextInfo <> ContextInfo.NoContext ->
| ErrorFromAddingTypeEquation(_, _, _, _, ((ConstraintSolverTypesNotInEqualityRelation (_, _, _, _, _, contextInfo) ) as e), _) when (match contextInfo with ContextInfo.NoContext -> false | _ -> true) ->
OutputExceptionR os e

| ErrorFromAddingTypeEquation(_, _, _, _, ((ConstraintSolverTypesNotInSubsumptionRelation _ | ConstraintSolverError _ ) as e), _) ->
Expand Down
2 changes: 2 additions & 0 deletions src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ type ContextInfo =
| FollowingPatternMatchClause of range
/// The type equation comes from a pattern match guard.
| PatternMatchGuard of range
/// The type equation comes from a sequence expression.
| SequenceExpression of TType

exception ConstraintSolverTupleDiffLengths of DisplayEnv * TType list * TType list * range * range
exception ConstraintSolverInfiniteTypes of ContextInfo * DisplayEnv * TType * TType * range * range
Expand Down
3 changes: 2 additions & 1 deletion src/fsharp/ConstraintSolver.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ type ContextInfo =
| FollowingPatternMatchClause of range
/// The type equation comes from a pattern match guard.
| PatternMatchGuard of range

/// The type equation comes from a sequence expression.
| SequenceExpression of TType

exception ConstraintSolverTupleDiffLengths of DisplayEnv * TType list * TType list * range * range
exception ConstraintSolverInfiniteTypes of ContextInfo * DisplayEnv * TType * TType * range * range
Expand Down
2 changes: 2 additions & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1422,3 +1422,5 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
3218,ArgumentsInSigAndImplMismatch,"The argument names in the signature '%s' and implementation '%s' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling."
3219,pickleUnexpectedNonZero,"An error occurred while reading the F# metadata of assembly '%s'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct."
3220,tcTupleMemberNotNormallyUsed,"This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead."
3221,implicitlyDiscardedInSequenceExpression,"This expression returns a value of type '%s' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'."
3222,implicitlyDiscardedSequenceInSequenceExpression,"This expression returns a value of type '%s' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'."
36 changes: 27 additions & 9 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ let ShrinkContext env oldRange newRange =
| ContextInfo.ReturnInComputationExpression
| ContextInfo.YieldInComputationExpression
| ContextInfo.RuntimeTypeTest _
| ContextInfo.DowncastUsedInsteadOfUpcast _ ->
| ContextInfo.DowncastUsedInsteadOfUpcast _
| ContextInfo.SequenceExpression _ ->
env
| ContextInfo.CollectionElement (b,m) ->
if m <> oldRange then env else
Expand Down Expand Up @@ -830,19 +831,35 @@ let ReportImplicitlyIgnoredBoolExpression denv m ty expr =
extractNext inner
| expr -> checkExpr m expr

let UnifyUnitType cenv denv m ty expr =
let UnifyUnitType cenv (env:TcEnv) m ty expr =
let denv = env.DisplayEnv
if AddCxTypeEqualsTypeUndoIfFailed denv cenv.css m ty cenv.g.unit_ty then
true
else
let domainTy = NewInferenceType ()
let resultTy = NewInferenceType ()
if AddCxTypeEqualsTypeUndoIfFailed denv cenv.css m ty (domainTy --> resultTy) then
warning (FunctionValueUnexpected(denv, ty, m))
else
if not (typeEquiv cenv.g cenv.g.bool_ty ty) then
warning (UnitTypeExpected (denv, ty, m))
else
warning (ReportImplicitlyIgnoredBoolExpression denv m ty expr)
else
let reportImplicitlyDiscardError() =
if typeEquiv cenv.g cenv.g.bool_ty ty then
warning (ReportImplicitlyIgnoredBoolExpression denv m ty expr)
else
warning (UnitTypeExpected (denv, ty, m))

match env.eContextInfo with
| ContextInfo.SequenceExpression seqTy ->
let lifted = mkSeqTy cenv.g ty
if typeEquiv cenv.g seqTy lifted then
warning (Error (FSComp.SR.implicitlyDiscardedInSequenceExpression(NicePrint.prettyStringOfTy denv ty), m))
else
if isListTy cenv.g ty || isArrayTy cenv.g ty || typeEquiv cenv.g seqTy ty then
warning (Error (FSComp.SR.implicitlyDiscardedSequenceInSequenceExpression(NicePrint.prettyStringOfTy denv ty), m))
else
reportImplicitlyDiscardError()
| _ ->
reportImplicitlyDiscardError()

false

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -5567,7 +5584,7 @@ and TcStmtThatCantBeCtorBody cenv env tpenv expr =
and TcStmt cenv env tpenv synExpr =
let expr, ty, tpenv = TcExprOfUnknownType cenv env tpenv synExpr
let m = synExpr.Range
let wasUnit = UnifyUnitType cenv env.DisplayEnv m ty expr
let wasUnit = UnifyUnitType cenv env m ty expr
if wasUnit then
expr, tpenv
else
Expand Down Expand Up @@ -8255,6 +8272,7 @@ and TcSequenceExpression cenv env tpenv comp overallTy m =
// seq { ...; expr } is treated as 'seq { ... ; expr; yield! Seq.empty }'
// Note this means seq { ...; () } is treated as 'seq { ... ; (); yield! Seq.empty }'
let m = comp.Range
let env = { env with eContextInfo = ContextInfo.SequenceExpression genOuterTy }
let expr, tpenv = TcStmtThatCantBeCtorBody cenv env tpenv comp
Expr.Sequential(expr, mkSeqEmpty cenv env m genOuterTy, NormalSeq, SuppressSequencePointOnStmtOfSequential, m), tpenv

Expand Down Expand Up @@ -10413,7 +10431,7 @@ and TcNormalizedBinding declKind (cenv:cenv) env tpenv overallTy safeThisValOpt
else TcExprThatCantBeCtorBody cenv overallExprTy envinner tpenv rhsExpr)

if bkind = StandaloneExpression && not cenv.isScript then
UnifyUnitType cenv env.DisplayEnv mBinding overallPatTy rhsExprChecked |> ignore<bool>
UnifyUnitType cenv env mBinding overallPatTy rhsExprChecked |> ignore<bool>

// Fix up the r.h.s. expression for 'fixed'
let rhsExprChecked =
Expand Down
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/fsharp/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6972,6 +6972,16 @@
<target state="new">This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield'.</target>
<note />
</trans-unit>
<trans-unit id="implicitlyDiscardedSequenceInSequenceExpression">
<source>This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</source>
<target state="new">This expression returns a value of type '{0}' but is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to use the expression as a value in the sequence then use an explicit 'yield!'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Loading