Skip to content
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

Handle break labels like variables. #260

Merged
merged 4 commits into from
Feb 21, 2025
Merged

Handle break labels like variables. #260

merged 4 commits into from
Feb 21, 2025

Conversation

01mf02
Copy link
Owner

@01mf02 01mf02 commented Feb 17, 2025

The offset mechanism previously used to deal with label ... break yielded wrong outputs in certain situations. For example, label $x | (def x: break $x; (label $y | x), 0) yields 0 in jaq 2.1.0, whereas it should yield empty (like jq).

This PR replaces the offset mechanism completely by a substitution mechanism that assigns break labels a unique index on the current execution path. This uses to a large extent the existing infrastructure for variables. Consequently, this corrects the execution of label ... break expressions.

I discovered this issue while reworking the formal jq specification.

The offset mechanism previously used yielded wrong outputs.
For example, `label $x | (def x: break $x; (label $y | x), 0)` yields
`0` in jaq 2.1.0, whereas it should yield `empty` (like jq).
We replace the offset mechanism completely by a substitution mechanism
that assigns break labels a unique index on the current execution path.
This uses to a large extent the existing infrastructure for variables.
@01mf02 01mf02 merged commit 9806586 into main Feb 21, 2025
3 checks passed
@01mf02 01mf02 deleted the label-vars branch February 21, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant