Skip to content

Fix pkl:test fact power assertions when member source section is unavailable#1571

Merged
HT154 merged 1 commit intoapple:mainfrom
HT154:test-facts-power-assertion-unavailable-source-section
May 4, 2026
Merged

Fix pkl:test fact power assertions when member source section is unavailable#1571
HT154 merged 1 commit intoapple:mainfrom
HT154:test-facts-power-assertion-unavailable-source-section

Conversation

@HT154
Copy link
Copy Markdown
Contributor

@HT154 HT154 commented May 4, 2026

Power assertions only work when the source section is available. If it is unavailable, power assertions throw a ParserError (unexpected EOF on an empty input) when re-parsing the expression for presentation.

@HT154 HT154 force-pushed the test-facts-power-assertion-unavailable-source-section branch from f0010b1 to 04bdbdb Compare May 4, 2026 18:57
Comment on lines +87 to +89
if (!sourceSection.isAvailable()) {
throw new PklBugException("Power assertions require an available source section");
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this check to simplify debugging similar issues in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an assertion here instead, e.g.

assert sourceSection.isAvailable() : "Power assertions require an available source section"

Assertions are there for conditions that we guarantee to be true, and (ideally) surface via our tests. They get compiled away when we build our executable.

@HT154 HT154 force-pushed the test-facts-power-assertion-unavailable-source-section branch from 04bdbdb to 1c2f586 Compare May 4, 2026 19:02
@HT154 HT154 merged commit b7ba6a8 into apple:main May 4, 2026
21 checks passed
@HT154 HT154 deleted the test-facts-power-assertion-unavailable-source-section branch May 4, 2026 19:25
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.

2 participants