Ref scoping#5240
Merged
TIHan merged 28 commits intodotnet:masterfrom Jul 2, 2018
Merged
Conversation
Contributor
|
@TIHan can you track the scoping rules in the RFC as well? We want the RFC to be the canonical source for these sorts of things. |
Contributor
Author
Contributor
Author
|
test Windows_NT Release_ci_part4 Build please |
… other than the method/function level
Contributor
Author
|
I found a bug last night and will need to fix it today. |
Contributor
Author
|
I believe this is now fully ready. One thing to note, I disallowed "implicit address of" for member methods with |
TIHan
added a commit
to TIHan/visualfsharp
that referenced
this pull request
Jul 2, 2018
* 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
TIHan
added a commit
that referenced
this pull request
Jul 2, 2018
* Enable negative byref tests (#5237) * Checking negative tests for byrefs * Added byref test baseline * 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds byref scoping.
Before, you could compile code like this:
As you can see, we can return the address of
yfrom the expression, out of the scope of where it was defined. Technically, this is valid and will run. However, we suspect that no one is doing this as doing such a thing has the potential to cause bugs, as shown here: #5235This change will restrict returning the address of values from where it was defined in an expression, effectively its visibility.