Skip to content

Prevent hidden variables from interfering with closures - #347

Merged
dstelzer merged 3 commits into
mainfrom
closure-hidden-variables
Sep 1, 2026
Merged

Prevent hidden variables from interfering with closures#347
dstelzer merged 3 commits into
mainfrom
closure-hidden-variables

Conversation

@dstelzer

Copy link
Copy Markdown
Contributor

Every div, span, and certain other constructions creates a hidden variable that's used for internal purposes.

These hidden variables should not be considered when determining if the inputs to a closure are bound or not.

For example, this source:

(style class @red) color: red;
(style class @green) color: green;

(interface (this should be bound $<This))
(this should be bound $This) $This

(program entry point)
	(query { (span @red) Red! })
	(query { (span @green) Green! })
	($B = 123)
	(query { (this should be bound $B) })

With the current compiler, it produces this:

Warning: closure-span.dg, line 11: Parameter #1 of (this should be bound $) can be (partially) unbound, which violates the interface declaration at closure-span.dg:4.
Warning: closure-span.dg, line 11: Parameter #1 of (this should be bound $) can be (partially) unbound, which violates the interface declaration at closure-span.dg:4.

Because the red and green spans introduce hidden variables that mean ( invoke-closure $ $ $) does not have fully-bound parameters.

With this PR, those hidden variables are not included in the signature of ( invoke-closure $ $ $) and thus will not be considered by the optimizer. Thus, no warnings.

This was previously reported as #291 and reported as fixed in #292 . However, that PR only fixed it for the debugger. This PR fixes it for the compiler as well.

@dstelzer

Copy link
Copy Markdown
Contributor Author

Fixes #291 properly this time

@dstelzer
dstelzer merged commit d3df8e2 into main Sep 1, 2026
4 checks passed
@dstelzer
dstelzer deleted the closure-hidden-variables branch September 1, 2026 23:07
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