# GSoC syncup: Match Expressions & Pattern Matching Rolling agenda. [Proposal](https://summerofcode.withgoogle.com/organizations/gnu-compiler-collection-gcc/programs/2025/proposals/details/o8jortO7) ## 2025-08-25 - PR to refactor REST-ful patterns in AST merged (thanks Pierre!) - [Spotted TODOs for `TupleStructItemsHasRest`](https://github.com/Rust-GCC/gccrs/blob/ed958757c03f41542425756cbd8b2c6a2b876191/gcc/rust/backend/rust-compile-pattern.cc#L359-L362), I realised I missed them out and am currently working on it. Probably will have a PR up by tomorrow. - Please check my final submission, I pasted a hackmd link in our chat :) ## 2025-08-18 - [Link to my draft for GSoC final submission](https://zhiheng.dev/gsoc2025/final-submission/) - Will submit it as a GitHub gist instead since that should be more permanent than my webpage link :) - Stuff from last week got merged 🎉 - Working on refactoring pattern items on AST to match my [refactor for the HIR.](https://github.com/Rust-GCC/gccrs/pull/4039) - Plan to work on resolving some pattern-related ICE issues afterwards. - https://github.com/Rust-GCC/gccrs/issues/3930 - https://github.com/Rust-GCC/gccrs/issues/3929 - https://github.com/Rust-GCC/gccrs/issues/3940 - https://github.com/Rust-GCC/gccrs/issues/3918 ## 2025-08-11 - ~~Slowly finishing up~~ [JUST FINISHED UP](https://github.com/Polygonalr/gccrs/pull/2/files) with final changes to fully implement rest pattern support for slice patterns. - Plan to go back to finishing up backlog items such as [adding var decl support for identifier pattern's subpatterns](https://github.com/Polygonalr/gccrs/commit/66d28743d4b4fb225df1ce09e5012c86c0a557fe) & `CompilePatternLet` support for all the unsupported patterns that I had worked on. - Will start on writing the final report in parallel meanwhile, to be hosted on my website. I'll aim to get a draft up by next week :) ## 2025-08-04 - AST support for rest pattern in slice patterns merged. - Opened a PR for a refactor patch to prep HIR changes yesterday (no rush to get it reviewed). - Currently working on finishing up the rest of the HIR changes, all the way including code gen, by this week. - No questions for the meeting, I think I got this :) ## 2025-07-28 - Plan for the upcoming week is to start on implementing rest pattern `[1, .., 3]` for slice patterns. - Need to update the parser and AST representation - referencing the code for parsing rest patterns for [`TuplePattern` here](https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/parse/rust-parse-impl.h#L10771). - Thing to take note: Code duplication exists in `TupleStructItems`, `TuplePatternItems` and (soon) `SlicePatternItems` - they are just used to represent a list of patterns within `TupleStructPattern`, `TuplePattern` and (soon) `SlicePattern` respectively. - I plan to ask Philip whether it is wise to combine them into one common class after I'm done with the above. ## 2025-07-21 - Midterms passed! :partying_face: - Done with the type-checking section as part of Philip's guide, still in the midst of implementing codegen for check expression for SlicePattern against SliceType reference scrutinee. - Need help with codegen that accesses slice elements, I don't think using `array_index_expression` is correct here because a slice is represented with a pointer. ## 2025-07-07 - Implementing type checking for `SlicePattern` against `ArrayType` parent, but capacity of `ArrayType` doesn't seem to be evaluated in compile time? - There is an explicit `FIXME` in the code: https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/typecheck/rust-tyty.h#L1196-L1198 - Can't seem to produce proper errors as a result, example from Rust Playground below: ```rust fn main() { let a = [1, 2]; match a { [0, 0, 0] => {} } } // playground console error[E0527]: pattern requires 3 elements but array has 2 --> src/main.rs:5:9 | 5 | [0, 0, 0] => {} | ^^^^^^^^^ expected 2 elements For more information about this error, try `rustc --explain E0527`. error: could not compile `playground` (bin "playground") due to 1 previous error ``` ## 2025-06-30 - Slowly working on fully implementing RestPattern compilation, 1 pending PR for review that implements RestPattern compilation for tuples. - Working on SlicePatterns next. - Another week of not having questions to ask 🙃 __Actions__: - Arthur to review PR https://github.com/Rust-GCC/gccrs/pull/3863/files ## 2025-06-23 - Uneventful, busy week for ZH 🫠 - Finished up fixing TupleStructPattern compilation errors, looking into RestPatterns next. ## 2025-06-16 - ZH: Working on fixing compilation of TupleStructPattern. - **Context**: From my prior debugging sessions, I learnt that enum patterns are treated as [TupleStructPattern](https://gist.github.com/Polygonalr/9dc5e7d05b5e162e420e8d6680dd6d8f#file-no-subpattern-rs-L97-L99) in the HIR. - I'm guessing that the code of `CompilePatternCheckExpr::visit (HIR::TupleStructPattern &pattern)` was updated at some point of time to make enum pattern compilation work, but the updated code did not account for how tuple structs are represented. This causes the [compilation of this example code snippet](https://github.com/Polygonalr/gccrs/blob/ef18be08e074709c968713f9b56e70ad66ea79d0/gcc/testsuite/rust/compile/match-tuplestructpattern.rs) to throw an error. - My strategy now is to update TupleStructPattern compilation to match StructPattern's. - Future improvements for IdentifierPatterns: - Update according to https://github.com/Rust-GCC/gccrs/pull/3822/files#r2149932447 - Update this to optional (low priority): https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/ast/rust-pattern.h#L77 ## 2025-06-09 - ZH: OK to leave further testing for later when time permits? I left a disclaimer that I haven't tested the IdentifierPattern code with complex subpatterns (if there are any that I need to take note of). - grep for `-frust-compile-until` in the testsuite __Actions__: - Zhi Heng to start investigating tuple struct patterns - Arthur to review PRs ## 2025-06-01 - Introduction - Zhi Heng's notes will be stored here https://zhiheng.dev/gsoc2025/ __Actions__: - Zhi Heng to write down questions if you have any :D - Arthur to setup a groupchat for PE and Zhi Heng