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.
Previously we've had a special type called
Scope
to differentiate function-localRef
s with different scopes, so that they can't be assigned to each other willy-nilly, and so that we can prevent usage of a reference when it goes out of scope. This PR removes those so now allRef
s with the sameinner
type are treated the same.The reason for this is that we need to treat scopes slightly more flexibly in #86; specifically, if you
Select
on twoRef
s, it's unclear which scope the result should have. It can't have its own new scope, because having its own scope means that it can beResolve
d later. But that problem goes away if bothRef
s are just the same type. Also, this removes an additional pass in transposition where we would need to keep track of what variables need to have new scope types added for them: with no scope types, that sort of self-referential-ness goes away.The reason we originally had scope types at all was because it seemed like differentiating them at the type level would make scopes easier to validate. But we already have to validate scopes of other kinds of variables, and this doesn't really seem different. All you need to do is ensure that
Ref
s introduced in a block getresolve
d later in that same block. Then for derivedRef
s, just have them point to the most recently defined non-derivedRef
that they use; this arises inSelect
, for instance. We already use this most-recently-defined idea inrose-web
for normal variables to deal with lazily-defined literals. Also, note that this behavior forSelect
constrains us to have scope nesting be properly matched: for instance, it wouldn't work to define twoRef
s and then later resolve them in non-reverse order, because then aSelect
edRef
would only get invalidated after the second one rather than the first one.