leanprover / leanprover/lean4

Error message regression for nested inductive types

Open
#8,960 1 comment 3 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

Description

The error message for certain invalid nested inductive types got much worse in recent nightlies.

Context

This arose while updating the language reference.

Steps to Reproduce
  1. Open a file in a Lean nightly from on or after 2025-06-21
    1. Enter the following code:
    import Std.Data.HashMap
    
    open Std
    
    structure Maze where
      description : String
      passages : HashMap String Maze
    
  2. Observe the error message

Expected behavior:
An error message that says something about nested occurrences, like the one emitted on 2025-06-20 and earlier:

(kernel) arg #1 of '_nested.Std.HashMap_1.mk' contains a non valid occurrence of the datatypes being declared

This message is not phrased in terms of what the user actually wrote, but rather internal elaboration artifacts, and it doesn't mention "nested inductive types", but it is at least a reasonable search term and can be improved from here.

Actual behavior:

A more confusing and less specific error message:

(kernel) application type mismatch
  DHashMap.Raw.WF inner
argument has type
  _nested.Std.DHashMap.Raw_3
but function has type
  (DHashMap.Raw String fun x => Maze) → Prop

This message makes it much harder diagnose the issue.

Versions

Nightlies from 2025-06-21 and later

Impact

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

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

Reproduce the issue with the supplied Maze and HashMap example in a Lean nightly from 2025-06-21 or later, then compare its diagnostic with the output from 2025-06-20 or earlier. Done means the nested inductive type error is specific and useful rather than exposing confusing internal elaboration artifacts.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.