chore: improve pattern matching (#9242)

This commit is contained in:
Cameron Zwarich 2025-07-07 20:36:34 -07:00 committed by GitHub
parent 05630fc149
commit 765f98770b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,10 +137,8 @@ partial def lowerLet (decl : LCNF.LetDecl) (k : LCNF.Code) : M FnBody := do
| .proj typeName i fvarId =>
match (← get).fvars[fvarId]? with
| some (.var varId) =>
-- TODO: have better pattern matching here
let some (.inductInfo { ctors, .. }) := (← Lean.getEnv).find? typeName
| panic! "projection of non-inductive type"
let ctorName := ctors[0]!
let some (.inductInfo { ctors := [ctorName], .. }) := (← Lean.getEnv).find? typeName
| panic! "projection of non-structure type"
let ⟨ctorInfo, fields⟩ ← getCtorLayout ctorName
let ⟨result, type⟩ := lowerProj varId ctorInfo fields[i]!
match result with