Skip to content

Conversation

@mccanne
Copy link
Collaborator

@mccanne mccanne commented Jan 13, 2026

This commit changes complex literals in the sem tree and DAG to always be represented by expressions. To enforce this, we changed sem.LiteralExpr and dag.LiteralExpr to PrimitiveExpr and created sem.NewLiteral() to handle all creations of complex literal values. NewLiteral() can also be used on primitive types as it creates a PrimitiveExpr for primitive types and an expression for complex literals.

This refactoring exposed the fact that complex literals could be handled by the bsup bufferfilter and the pruning logic in the optimizer. With these changes, bufferfilter and pruning is now limited to primitive types.

We also fixed super.NewTypeValue which was using the wrong type ID.

This commit changes complex literals in the sem tree and DAG
to always be represented by expressions.  To enforce this,
we changed sem.LiteralExpr and dag.LiteralExpr to PrimitiveExpr
and created sem.NewLiteral() to handle all creations of complex
literal values.  NewLiteral() can also be used on primitive types
as it creates a PrimitiveExpr for primitive types and an expression
for complex literals.

This refactoring exposed the fact that complex literals could
be handled by the bsup bufferfilter and the pruning logic in the
optimizer.  With these changes, bufferfilter and pruning is
now limited to primitive types.

We also fixed super.NewTypeValue which was using the wrong type ID.
func NewIP(a netip.Addr) Value { return NewValue(TypeIP, EncodeIP(a)) }
func NewNet(p netip.Prefix) Value { return NewValue(TypeNet, EncodeNet(p)) }
func NewTypeValue(t Type) Value { return NewValue(TypeNet, EncodeTypeValue(t)) }
func NewTypeValue(t Type) Value { return NewValue(TypeType, EncodeTypeValue(t)) }
Copy link
Member

Choose a reason for hiding this comment

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

Yikes. This bug's been here since I added NewTypeValue in January 2023.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

LOL

@mccanne mccanne merged commit 404c0ea into main Jan 14, 2026
2 checks passed
@mccanne mccanne deleted the complex-literals branch January 14, 2026 16:59
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.

4 participants