Skip to content

Store required features in bindings - #8402

Closed
saecki wants to merge 4 commits into
foreign-capability-implsfrom
feature-gated-bindings
Closed

saecki wants to merge 4 commits into
foreign-capability-implsfrom
feature-gated-bindings

Conversation

@saecki

@saecki saecki commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

Based on #8571

This defers providing enabled library features until accessing a binding.
It also allows generating a nicer error message for feature gated bindings, instead of just saying it is undefined.

Here's an example of an error message before:

error: unknown variable: html
  ┌─ test.typ:1:1
  │
1 │ #html.div()
  │  ^^^^

and here the same one after:

error: cannot access variable `html` because the `html` feature is not enabled
  ┌─ test.typ:1:1
  │
1 │ #html.div()
  │  ^^^^

We still have to check that this doesn't hurt performance, since read_checked is a somewhat hot function.

There are currently no tests implemented, because that would require changing the TestWorld features, which is a bit of a pain and I first want to check for performance regressions.

@saecki
saecki force-pushed the feature-gated-bindings branch 2 times, most recently from 2cbe89c to a50eb4f Compare June 3, 2026 15:03
@laurmaedje laurmaedje added diagnostics Improvements to compiler errors refactor A refactoring. labels Jun 4, 2026
@saecki
saecki force-pushed the feature-gated-bindings branch 4 times, most recently from de31d7c to f71c785 Compare June 10, 2026 18:10
@saecki
saecki force-pushed the feature-gated-bindings branch from f71c785 to f238dba Compare June 12, 2026 12:08
@saecki saecki mentioned this pull request Jun 12, 2026
14 tasks done
@saecki
saecki force-pushed the feature-gated-bindings branch 2 times, most recently from c9fbc15 to 5b2ef2d Compare June 19, 2026 12:51
@saecki
saecki changed the base branch from main to pretty-nested-svg June 19, 2026 12:55
@Marcono1234

Copy link
Copy Markdown
Contributor

It also allows generating a nicer error message for feature gated bindings, instead of just saying it is undefined.

It seems there is no dedicated issue for this yet (at least I did not find one), and I just encountered that error and was a bit confused at first.

Would it be useful if I created a dedicated issue for requesting such nicer error messages for this situation?
(To account for the risk that this PR here is not merged due to performance concerns; because maybe it would be possible to implement those nicer errors on its own in a performant way?)

@saecki

saecki commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

We definitely want to merge a version of this PR. We're just cautious regarding any performance regressions but optimizing the binding accesses shouldn't be a big issue.

@saecki
saecki force-pushed the feature-gated-bindings branch 3 times, most recently from 10623db to 440528d Compare June 25, 2026 16:13
@saecki
saecki changed the base branch from pretty-nested-svg to foreign-capability-impls June 25, 2026 16:14
@saecki
saecki force-pushed the foreign-capability-impls branch from 07d0c96 to 3caad47 Compare June 30, 2026 10:50
saecki added 2 commits June 30, 2026 12:50
This defers providing enabled library features until accessing a binding.
It also allows generating a nicer error message for feature gated
bindings, instead of just saying it is undefined.
@saecki
saecki force-pushed the feature-gated-bindings branch from 440528d to c4a1149 Compare June 30, 2026 10:53
@saecki
saecki force-pushed the foreign-capability-impls branch 2 times, most recently from 5e5422f to 4f11ef5 Compare June 30, 2026 15:16
@saecki
saecki deleted the branch foreign-capability-impls June 30, 2026 16:29
@saecki saecki closed this Jun 30, 2026
@saecki saecki changed the title Store required feature in bindings Store required features in bindings Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics Improvements to compiler errors refactor A refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants