leanprover / leanprover/lean4

Application type mismatch with _nested argument

Open
#4,964 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

The following code

namespace List
  def keys (pairs : List (α × β)) : List α
    := match pairs with
      | [] => []
      | ⟨a, _⟩ :: rest => a :: keys rest

  def values (pairs : List (α × β)) : List β
    := match pairs with
      | [] => []
      | ⟨_, b⟩ :: rest => b :: values rest
end List

inductive Term : Type where
  | var : String → Term
  | app : Term → Term → Term
  | lam : String → Term → Term
  | record : (entries : List (String × Term)) → (unique : entries.keys.Nodup) → Term

results in an error:

application type mismatch
  List.keys entries
argument has type
  _nested.List_1
but function has type
  List (String × Term) → List String
Context

People on Lean Zulip suggested to file a bug report.

Steps to Reproduce

Put the code above into VSCode editor, wait for lean infoview to execute.

Expected behavior: The code should type check

Actual behavior: Error thrown

Versions

Lean version: 4.11.0-rc1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproducer in the issue in the VSCode editor or on the Lean nightly release, focusing on the application type mismatch involving the _nested argument and List.keys. Confirm the behavior against the stated Lean 4.11.0-rc1 version and latest nightly; done when the example type checks without the reported error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.