-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when are symbolic values resolved under the one-step equality rule? #1384
Comments
One possible answer is that the This may only be part of an answer, however: if we have |
I do want the code in the example to be legal. How much can we keep track of the value and type separately? Treating
|
It's not clear to me that we want to treat
... I think we previously had said we wanted a type-checking failure, because
|
(In your second example, was the first I think it's okay to require |
This is definitely intertwined with the question from #1369 . When you say "we previously had said we wanted a type-checking failure, because The
But it is an experiment since there are definite downsides that may outweigh the benefits. In particular, I feel like your recent work has been calling into question whether this rule is easy to predict and has been coming up with a variety of situations where |
That makes sense to me, but that's going beyond what I want to ask in the context of this question, and I think is a significant part of what #1369 is exploring. The context that I'd intended for this question is: assuming that we stick with the one-step equality rule, how do we answer this question? I've updated the summary of this issue to reflect that. If the answer is that we don't have a good answer, that's definitely strongly pushing towards a different set of rules, but I'd like to explore whether we can make the current ruleset work before we try something else that will very likely present a different set of tricky questions -- that is, I want to complete the one-step equality experiment so we have a concrete comparison point, and this question seems to be on the critical path to that goal.
I think we might want to somehow track the type, the symbolic value, and perhaps the concrete value separately. The fact that Some options to consider:
|
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the |
@zygoloid #2173 changes the calculus here: We expect to use |
I think that gives us the possibility of having a simple answer: we can refuse to perform any calculation on a symbolic value such as A somewhat related case is:
Does that last line compile? (Does the third line even compile?) I guess the question here is, if we have a concrete
No rewrite happens here, because we have no member access naming Some options:
Option (5) is probably easy to eliminate because I don't think it's computable in full generality, for the usual reasons that transitive equality is hard. Option (1) seems substantially too restrictive to me, and option (4) seems to be granting It seems like there are two variants to consider: a) Any compile-time evaluation of Option (b) seems appealing, but still has some oddness:
I wonder if we can get away with (2a). That seems like the cleanest and simplest model, but it's restrictive. Alternatively, we could try also performing rewrites on any symbolic values produced by constant evaluation, but that would still reject We should also look at examples of type expressions, where I think there will be strong pressure for something like (b) to work. I think we need some more discussion and exploration of options here. |
It seems to me that the third line compiles, I'm not even sure what the question is.
This again depends on the resolution of #2153 . My understanding of our resolution of #2153 is that the checked-to-template conversion that happens when instantiating
I believe the answer is neither -- it succeeds without using the constraint. That is to say, it would still succeed even if that constraint were not present.
This statement disagrees with the way I understand we are leaning on #2153 . |
Consider:
Generally when we see an expression like
X.T
orX.N
, we want to preserve it symbolically, even if we can resolve it to a constant --X.T
andi32
are different symbolic type values, even though we know they refer to the same type. For example, the type ofa[0]
inF
should beX.T
, noti32
, so thata[0].FooFunc
finds the member of interfaceFoo
.But what should happen when we see the declaration of
b
, and in particularX.N + 1
? Do we at some point switch from viewingX.N
as a symbolic reference to the associated constantN
and replace it with the corresponding known value of2
, and if so, when does that happen? Is the type ofb
exactly equivalent toArray(X.T, 3)
so that the initializer type-checks, or is it simply an error to attempt to perform an addition on the symbolic valueX.N
?The text was updated successfully, but these errors were encountered: