Skip to content

"unsupported pattern in syntax match" at wrong spot #8304

Open
@Happyves

Description

@Happyves

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

MWE:

import Lean.Meta.Basic

open Lean Meta

def test1 : Nat := 
  let a : (Sum Nat Nat) := .inr 1
  let b : (Sum Nat Nat) := .inl 1
  let c : (Sum Nat Nat) := .inr 1
  match a, b, c with
  | .inr x , .inl y, inr z => return x+y+z
  | _,_,_ => return 37

def test2 : MetaM Nat:= do
  let a : MetaM (Sum Nat Nat) := return .inr 1
  let b : MetaM (Sum Nat Nat) := return .inl 1
  let c : MetaM (Sum Nat Nat) := return .inr 1
  match ← a, ← b, ← c with
  | .inr x , .inl y, inr z => return x+y+z
  | _,_,_ => return 37

def test3 : MetaM Nat:= do
  let a : MetaM (Sum Nat Nat) := return .inr 1
  let b : MetaM (Sum Nat Nat) := return .inl 1
  let c : MetaM (Sum Nat Nat) := return .inr 1
  let a ← a
  let b ← b
  let c ← c
  match a, b, c with
  | .inr x , .inl y, inr z => return x+y+z
  | _,_,_ => return 37

In test1, the correct error message invalid pattern, constructor ... is thrown, but in the two others, we get the incorrect unsupported pattern in syntax match .inr x

Context

No discussion on Zulip.

Steps to Reproduce

  1. Copy mwe into live.lean

Expected behavior: Get test2 and test3 to display the same error as test1

Actual behavior: Incorrect error message

Versions

"4.21.0-nightly-2025-05-12"
live.lean-lang.org

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumWe may work on this issue if we find the timebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions