-
Notifications
You must be signed in to change notification settings - Fork 292
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
internal/eval: strange let declaration behaviour #1116
Comments
@myitcv Is this related to the fact that
Or is this working as intended ? |
That is working as intended AFAICT. From the spec:
|
I think
Is a separate issue. It should probably not result in a valid parse. |
Minimal reproducer of the above:
|
Analysis: A solution would be to not store incomplete errors. But this may lead to exponential runtime. A better solution would be treat |
Will submit a fix for the original problem. Note that the unrelated issue of a |
See also:
|
These may be resolved later. Issue #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc
These may be resolved later. Issue #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc Signed-off-by: Paul Jolly <[email protected]>
These may be resolved later. Issue #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc Signed-off-by: Marcel van Lohuizen <[email protected]>
These may be resolved later. Issue #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc Signed-off-by: Marcel van Lohuizen <[email protected]>
These may be resolved later. Issue #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc Signed-off-by: Marcel van Lohuizen <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/528052 Reviewed-by: Marcel van Lohuizen <[email protected]>
Further reproducer of the
Which gives the output:
Notice the failure for the second |
Regarding the latter, the issue seems to occur when the reference is nested, so
gives the right input, but using |
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7 Signed-off-by: Marcel van Lohuizen <[email protected]>
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7 Signed-off-by: Marcel van Lohuizen <[email protected]>
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7 Signed-off-by: Marcel van Lohuizen <[email protected]>
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7 Signed-off-by: Marcel van Lohuizen <[email protected]>
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes #1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7 Signed-off-by: Marcel van Lohuizen <[email protected]>
These may be resolved later. Issue cue-lang#1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I46b8dda41193b41f5b6b0fd341164a2568697bfc Signed-off-by: Marcel van Lohuizen <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/528052 Reviewed-by: Marcel van Lohuizen <[email protected]> Signed-off-by: Joel Longtine <[email protected]>
This is a hacky fix that relies on the original let AST expression to be present in the ADT. In practice this will almost certainly always be the case, though. As part of this, the name uniquer has been fixed to remember the random number. The exporter methods were defined on the value, instead of the pointer type, so the random generator was created on each instance. The first few numbers are now fixed, to have more sane numbers in the majority of cases. This algorithm has the additional property that if an expression refers to a let that is not exported, the expression will be inlined. This does not give the correct result if this expression itself contains references, but that is a general problem with the current exporter. NOTE: the filepath substitution is incorrect in value mode. The original was incorrect as well, however, as the alias also was inserted in the wrong scope. In practice this only matters for the already broken `eval`. In export it would always generate an error anyway. Unique name generator comment moved to where it applies. Fixes cue-lang#1116 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I31c05485a5af4d9b423c71bd4e51fc05b5d4a5d7 Signed-off-by: Marcel van Lohuizen <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/528214 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]> Signed-off-by: Joel Longtine <[email protected]>
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Consider the following:
cue export working.cue
behaves as expected:However,
cue eval working.cue
looks incorrect; notice thelet
declaration has shifted scope. This could, however, be a presentational issue:Now consider
cue export broken.cue
:The trigger for this appears to be the fact that
List
is referenced from the index expression (noting however thatList + List
also fails with the same error). Contrastworking.cue
where the plain use ofList
works just fine.cue eval broken.cue
also looks "broken" in the same way asworking.cue
:What did you expect to see?
cue eval
showing thelet
expression in the correct scopecue export
to not error in either case.What did you see instead?
As above.
The text was updated successfully, but these errors were encountered: