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.
@dank-openai
dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from 1f8ad42 to cd405f4 Compare June 23, 2026 23:45
Comment thread xls/dslx/frontend/ast.h Outdated
Comment thread xls/dslx/frontend/parser.cc Outdated
Comment thread xls/dslx/fmt/ast_fmt_test.cc Outdated
Comment thread xls/dslx/frontend/ast.h
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Jul 21, 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.
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Jul 24, 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.
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Jul 25, 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.
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Jul 27, 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.
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Aug 6, 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.
@dank-openai
dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from cd405f4 to 5df31da Compare August 6, 2026 21:24
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Aug 6, 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.
@dank-openai
dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from 5df31da to c2d86b2 Compare August 6, 2026 23:46
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Aug 7, 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.
@dank-openai
dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from c2d86b2 to 22399dd Compare August 7, 2026 02:19
dank-openai added a commit to xlsynth/xlsynth that referenced this pull request Aug 7, 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.
@dank-openai
dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from 22399dd to 190276e Compare August 7, 2026 03:22
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 added a commit to xlsynth/xlsynth that referenced this pull request Aug 7, 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.
@dank-openai
dank-openai force-pushed the dank/upstream/semantic-sum-frontend branch from 190276e to 46b894a Compare August 7, 2026 19:49
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