Skip to content

dslx: parse semantic sum declarations and constructors#4457

Open
dank-openai wants to merge 1 commit into
google:mainfrom
xlsynth:dank/upstream/semantic-sum-frontend
Open

dslx: parse semantic sum declarations and constructors#4457
dank-openai wants to merge 1 commit into
google:mainfrom
xlsynth:dank/upstream/semantic-sum-frontend

Conversation

@dank-openai

@dank-openai dank-openai commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add DSLX frontend support for semantic-sum enum declarations with unit, tuple, and struct payload variants.
  • Add semantic-sum constructor expressions and match payload patterns so the AST preserves the source payload shape.
  • Teach formatting, cloning, LSP symbols, type-info plumbing, conversion scaffolding, and diagnostics about the new AST nodes while leaving full typechecking and lowering semantics for follow-up work.
  • Preserve existing numeric-enum parsing behavior, including explicitly typed empty enums.

Example

enum Option<T: type> {
  None,
  Some(T),
}

This PR makes declarations and constructors like Option::Some(x) parse and format as semantic-sum syntax. Later changes can build typechecking and conversion semantics on top of these AST nodes.

Validation

Validation ran on Ubuntu 24.04 at commit 1f8ad4299fa61d5d35d2bbd4fe4780f79314f2d8:

  • bazel test //xls/dslx/fmt:ast_fmt_test //xls/dslx/frontend:parser_test //xls/dslx/frontend:ast_cloner_test //xls/dslx/frontend:scanner_test //xls/dslx:dslx_fmt_test //xls/dslx:constexpr_evaluator_test //xls/dslx/bytecode:bytecode_emitter_test //xls/dslx/exhaustiveness:exhaustiveness_match_test //xls/dslx/lsp:document_symbols_test //xls/dslx/translators:dslx_to_verilog_test //xls/fuzzer:value_generator_test //xls/dslx/ir_convert:ir_converter_test //xls/dslx/ir_convert:ir_converter_legacy_test //xls/dslx/tests/errors:error_modules_test //xls/dslx/run_routines:run_routines_test //xls/dslx/type_system:type_info_to_proto_test //xls/dslx/type_system_v2:typecheck_module_v2_enum_test --test_output=errors --keep_going --test_timeout=900 --cache_test_results=no

Misc.

This is PR 1/7 for phase 1 implementation of sum types.

@dank-openai dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from 19ce53c to 1f8ad42 Compare June 23, 2026 22:02
@dank-openai dank-openai requested a review from richmckeever June 23, 2026 23:28
@dank-openai dank-openai marked this pull request as ready for review June 23, 2026 23:28
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Jun 23, 2026
Adds Phase 1 semantic sum value representation and encoding support, including diagnostics and tests for sum type mismatch formatting.
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Jun 23, 2026
…uctors

Adds frontend parsing, formatting, visitors, and diagnostics for semantic sum syntax while preserving typed empty numeric enum parsing until semantic-sum runtime/type support lands higher in the stack.
Adds frontend parsing, formatting, visitors, and diagnostics for semantic sum syntax while preserving typed empty numeric enum parsing until semantic-sum runtime/type support lands higher in the stack.

branch:dank/upstream/semantic-sum-frontend
@dank-openai dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from 1f8ad42 to cd405f4 Compare June 23, 2026 23:45
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