-
Notifications
You must be signed in to change notification settings - Fork 279
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
fix: style relation checker using substance variables #1239
Conversation
Deploying with Cloudflare Pages
|
± Registry diff
📊 PerformanceKeyNote that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.
Data
|
Codecov Report
@@ Coverage Diff @@
## main #1239 +/- ##
==========================================
+ Coverage 63.13% 63.45% +0.32%
==========================================
Files 60 61 +1
Lines 7061 7170 +109
Branches 1646 1664 +18
==========================================
+ Hits 4458 4550 +92
- Misses 2519 2537 +18
+ Partials 84 83 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Just to clarify, does #1123 become fixed via this PR? If so, could you modify your PR description autoclose it using GitHub's special syntax? https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue |
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks Leo! Just one minor comment.
Co-authored-by: Sam Estep <sam@samestep.com>
Co-authored-by: Sam Estep <sam@samestep.com>
Description
Related issue/PR: #1123
This PR fixes the uncaught error in the Style compiler when selector relations refer to a variable not declared in the selector, but exists in the substance program. It now throws an error. We added a test case on this error. Finally, we improved upon how the "suggested" variables in the error message distinguish between Style and Substance variables.
Implementation strategy and design decisions
The style compiler checks through the relations in the
where
clause, primarily using functions within the Substance checker, which checks the consistency of expressions with respect to aSubstanceEnv
. In particular, it checks that each variable referred in the expressions are declared insideSubstanceEnv
.In order to call the Substance checker, we would need to provide a
SubstanceEnv
that contains all the variables that we want the relations to be able to access. Previously, we just take the currentSubstanceEnv
(as used in the Substance program), and add all the variables declared in the style header. The problem is that now thisSubstanceEnv
contains both variables declared in the style header (which we want to be able to access) and variables not declared in the style header but exists in the substance program.The solution is simply to create a new, empty
SubstanceEnv
and add in the variables declared in the style header.Examples with steps to reproduce them
This is the same example as used in the original issue, running in the version in this PR. Previously, this did not trigger an error, and only fails silently under the browser console. Now it does trigger a sensible error.
Checklist