carbon-language/carbon-lang

Support for struct patterns

開放

#6,680 建立於 2026年2月2日

 (7 則留言) (0 個反應) (0 位負責人)C++ (1,535 個分叉)batch import
good first issuetoolchain

倉庫指標

星標
 (33,701 顆星)
PR 合併指標
 (平均合併 3天 6小時) (30 天內合併 129 個 PR)

描述

The Carbon toolchain is missing support for struct patterns, as documented here. As "first issues" go, this is probably fairly complex, but there are a couple ways of breaking it down to make it more manageable:

  • You can split it up by compilation phase, implementing parsing, then checking, then lowering in separate PRs (I don't think this will need changes to lexing).
  • You can split it up into sub-features: the core {.foo = foo: Foo, .bar = bar: Bar} syntax, and then the {foo: Foo, bar: Bar} shorthand and the trailing , _ syntax.

I'd recommend doing both: have each PR focus on a single phase of a single feature, and probably do all three phases of the core feature before starting on the shorthand or trailing , _ syntaxes.

Be sure to take a look at the toolchain docs, especially the one about pattern matching, if you're not already familiar with them. The existing support for tuple patterns should also be a useful point of reference, because the two features have a lot in common.

貢獻者指南