Skip to content

Commit 9f574f5

Browse files
committed
style: consolidate error message construction
1 parent 347de2f commit 9f574f5

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Lean/Elab/MutualInductive.lean

+4-8
Original file line numberDiff line numberDiff line change
@@ -970,18 +970,14 @@ private def checkNoInductiveNameConflicts (elabs : Array InductiveElabStep1) : T
970970
for { view, .. } in elabs do
971971
let typeDeclName := privateToUserName view.declName
972972
if let some (prevNameIsType, prevRef) := uniqueNames[typeDeclName]? then
973-
if prevNameIsType then
974-
throwErrorsAt prevRef view.declId m!"cannot define multiple inductive types with the same name '{typeDeclName}'"
975-
else
976-
throwErrorsAt prevRef view.declId m!"cannot define an inductive type and a constructor with the same name '{typeDeclName}'"
973+
let declKinds := if prevNameIsType then "multiple inductive types" else "an inductive type and a constructor"
974+
throwErrorsAt prevRef view.declId m!"cannot define {declKinds} with the same name '{typeDeclName}'"
977975
uniqueNames := uniqueNames.insert typeDeclName (true, view.declId)
978976
for ctor in view.ctors do
979977
let ctorName := privateToUserName ctor.declName
980978
if let some (prevNameIsType, prevRef) := uniqueNames[ctorName]? then
981-
if prevNameIsType then
982-
throwErrorsAt prevRef ctor.declId m!"cannot define an inductive type and a constructor with the same name '{typeDeclName}'"
983-
else
984-
throwErrorsAt prevRef ctor.declId m!"cannot define multiple constructors with the same name '{ctorName}'"
979+
let declKinds := if prevNameIsType then "an inductive type and a constructor" else "multiple constructors"
980+
throwErrorsAt prevRef ctor.declId m!"cannot define {declKinds} with the same name '{ctorName}'"
985981
uniqueNames := uniqueNames.insert ctorName (false, ctor.declId)
986982

987983
private def applyComputedFields (indViews : Array InductiveView) : CommandElabM Unit := do

0 commit comments

Comments
 (0)