chore: break up universe level error message (#9637)

This PR improves the readability of the "maximum universe level offset
exceeded" error message.
This commit is contained in:
jrr6 2025-07-30 19:52:53 -04:00 committed by GitHub
parent b8e801ecad
commit 3a3c816a27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -56,7 +56,9 @@ register_builtin_option maxUniverseOffset : Nat := {
private def checkUniverseOffset [Monad m] [MonadError m] [MonadOptions m] (n : Nat) : m Unit := do
let max := maxUniverseOffset.get (← getOptions)
unless n <= max do
throwError "maximum universe level offset threshold ({max}) has been reached, you can increase the limit using option `set_option maxUniverseOffset <limit>`, but you are probably misusing universe levels since offsets are usually small natural numbers"
throwError m!"Universe level offset `{n}` exceeds maximum offset `{max}`"
++ .note m!"This code is probably misusing universe levels, since they are usually small natural numbers. \
If you are confident this is not the case, you can increase the limit using `set_option maxUniverseOffset <limit>`"
partial def elabLevel (stx : Syntax) : LevelElabM Level := withRef stx do
let kind := stx.getKind

View file

@ -1,2 +1,6 @@
bigUnivOffsets.lean:1:12-1:21: error: maximum universe level offset threshold (32) has been reached, you can increase the limit using option `set_option maxUniverseOffset <limit>`, but you are probably misusing universe levels since offsets are usually small natural numbers
bigUnivOffsets.lean:5:13-5:25: error: maximum universe level offset threshold (32) has been reached, you can increase the limit using option `set_option maxUniverseOffset <limit>`, but you are probably misusing universe levels since offsets are usually small natural numbers
bigUnivOffsets.lean:1:12-1:21: error: Universe level offset `100000000` exceeds maximum offset `32`
Note: This code is probably misusing universe levels, since they are usually small natural numbers. If you are confident this is not the case, you can increase the limit using `set_option maxUniverseOffset <limit>`
bigUnivOffsets.lean:5:13-5:25: error: Universe level offset `10000000` exceeds maximum offset `32`
Note: This code is probably misusing universe levels, since they are usually small natural numbers. If you are confident this is not the case, you can increase the limit using `set_option maxUniverseOffset <limit>`