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

Commit32a93aa

Browse files
authored
Ref scoping (#5240)
* Added Limit* Trying to get basic scopes* Basic scope checks* Some more checks* Handling another ref scope case* Using env instead of cenv* Partially scoped* Almost figuring out scoping* Scopes are working* Check returnable* Current tests passing* Removed compiler generated rhs* Minor cleanup* Added scoping tests* Adding tests again* Scoping now determines what is local* Updated tests/baseline for byrefs. Simplified compiler generated check* Trivial change for scope check* Fixed bug with stack referring span-likes returning by-refs in scopes other than the method/function level* Quick fix* Preventing taking address of expression that isn't a let-bound value* Updated baseline* Updated baseline* Added better way to disable address of* Finishing up. Updating baselines* Updating neg106 baseline* Updated baselines again* Removing compiler generated check by fixing GetLimitVal
1 parent76dd383 commit32a93aa

31 files changed

+521
-135
lines changed

‎src/buildfromsource/FSharp.Compiler.Private/FSComp.fs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,6 +4351,9 @@ type internal SR private() =
43514351
/// A Span or IsByRefLike value returned from the expression cannot be used at ths point. This is to ensure the address of the local value does not escape its scope.
43524352
/// (Originally from ..\FSComp.txt:1441)
43534353
static memberchkNoSpanLikeValueFromExpression()=(3237, GetStringFunc("chkNoSpanLikeValueFromExpression",",,,"))
4354+
/// Cannot take the address of the value returned from the expression. Assign the returned value to a let-bound value before taking the address.
4355+
/// (Originally from ..\FSComp.txt:1442)
4356+
static membertastCantTakeAddressOfExpression()=(3238, GetStringFunc("tastCantTakeAddressOfExpression",",,,"))
43544357

43554358
/// Call this method once to validate that all known resources are valid; throws if not
43564359
static memberRunStartupValidation()=
@@ -5766,4 +5769,5 @@ type internal SR private() =
57665769
ignore(GetString("chkNoByrefLikeFunctionCall"))
57675770
ignore(GetString("chkNoSpanLikeVariable"))
57685771
ignore(GetString("chkNoSpanLikeValueFromExpression"))
5772+
ignore(GetString("tastCantTakeAddressOfExpression"))
57695773
()

‎src/buildfromsource/FSharp.Compiler.Private/FSComp.resx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,4 +4354,7 @@
43544354
<dataname="chkNoSpanLikeValueFromExpression"xml:space="preserve">
43554355
<value>A Span or IsByRefLike value returned from the expression cannot be used at ths point. This is to ensure the address of the local value does not escape its scope.</value>
43564356
</data>
4357+
<dataname="tastCantTakeAddressOfExpression"xml:space="preserve">
4358+
<value>Cannot take the address of the value returned from the expression. Assign the returned value to a let-bound value before taking the address.</value>
4359+
</data>
43574360
</root>

‎src/fsharp/FSComp.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,4 +1438,5 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
14381438
3234,chkStructsMayNotReturnAddressesOfContents,"Struct members cannot return the address of fields of the struct by reference"
14391439
3235,chkNoByrefLikeFunctionCall,"The function or method call cannot be used at this point, because one argument that is a byref of a non-stack-local Span or IsByRefLike type is used with another argument that is a stack-local Span or IsByRefLike type. This is to ensure the address of the local value does not escape its scope."
14401440
3236,chkNoSpanLikeVariable,"The Span or IsByRefLike variable '%s' cannot be used at this point. This is to ensure the address of the local value does not escape its scope."
1441-
3237,chkNoSpanLikeValueFromExpression,"A Span or IsByRefLike value returned from the expression cannot be used at ths point. This is to ensure the address of the local value does not escape its scope."
1441+
3237,chkNoSpanLikeValueFromExpression,"A Span or IsByRefLike value returned from the expression cannot be used at ths point. This is to ensure the address of the local value does not escape its scope."
1442+
3238,tastCantTakeAddressOfExpression,"Cannot take the address of the value returned from the expression. Assign the returned value to a let-bound value before taking the address."

‎src/fsharp/MethodCalls.fs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ let AdjustCalledArgType (infoReader:InfoReader) isConstraint (calledArg: CalledA
134134

135135
// If the called method argument is an inref type, then the caller may provide a byref or value
136136
if isInByrefTy g calledArgTythen
137+
#if IMPLICIT_ADDRESS_OF
137138
if isByrefTy g callerArgTythen
138139
calledArgTy
139140
else
140141
destByrefTy g calledArgTy
142+
#else
143+
calledArgTy
144+
#endif
141145

142146
// If the called method argument is a (non inref) byref type, then the caller may provide a byref or ref.
143147
elif isByrefTy g calledArgTythen

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp