Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

$$ is different in block versus in &requires #1914

Closed
evantypanski opened this issue Nov 4, 2024 · 0 comments · Fixed by #1926
Closed

$$ is different in block versus in &requires #1914

evantypanski opened this issue Nov 4, 2024 · 0 comments · Fixed by #1926
Assignees

Comments

@evantypanski
Copy link
Contributor

Found via bbannier/spicy-lint#54

Given this program:

module Test;

public type Data = unit {
    x: uint8 &convert=($$ + 5) &requires=($$ < 50) {
        print $$ < 50;
    }
};

I would expect in to print True every time since the &requires succeeded, but instead it may print False:

$ echo '0' | spicy-driver test.spicy
False

I think $$ should continue to refer to the pre-conversion value, personally, but instead it refers to the pre-conversion value in &requires, but after-conversion value in the block.

@evantypanski evantypanski self-assigned this Nov 20, 2024
evantypanski added a commit that referenced this issue Nov 20, 2024
Fixes #1914

`$$` says it refers to the pre-conversion value, but that's not true
within a hook. This fixes that so that `$$` always refers to the
pre-conversion value.
evantypanski added a commit that referenced this issue Nov 22, 2024
Closes #1914

The documentation would refer to `$$` in an attribute and hook with
similar language (the "parsed" value). But, in an attribute, it refers
to the value before any conversions. In a hook, it refers to the value
after any conversions.

Now, "parsed" is used to refer to the pre-conversion value, and "final"
is used to refer to the post-conversion value. Those terms were chosen
because they make sense when no conversions are applied (or when `$$` is
used *in* a conversion). But, "final" can still be a little confusing,
since you can write to `$$`.
@rsmmr rsmmr closed this as completed in 0a22b33 Nov 25, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant