fix: Panic edge case for module name

This commit is contained in:
Leni Aniva 2025-02-24 15:45:31 -08:00
parent 4435a6459c
commit 76639d0266
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
1 changed files with 5 additions and 2 deletions

View File

@ -25,7 +25,10 @@ def env_catalog (env: Environment): Array Name := env.constants.fold (init := #[
@[export pantograph_environment_module_of_name]
def module_of_name (env: Environment) (name: Name): Option Name := do
let moduleId ← env.getModuleIdxFor? name
return env.allImportedModuleNames.get! moduleId.toNat
if h : moduleId.toNat < env.allImportedModuleNames.size then
return env.allImportedModuleNames.get moduleId.toNat h
else
.none
def toCompactSymbolName (n: Name) (info: ConstantInfo): String :=
let pref := match info with