Skip to content

Commit 8f88393

Browse files
committed
chore: use backticks instead of single quotes for identifiers in messages
This PR standardizes the formatting of identifiers in error messages, warnings, and diagnostics by using backticks instead of single quotes. For example, `declaration uses 'sorry'` is now `declaration uses `sorry``. This is a style improvement that makes code identifiers stand out better in error messages and aligns with the convention used elsewhere in the codebase where backticks are used for code formatting.
1 parent cc89a85 commit 8f88393

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+179
-179
lines changed

src/Lean/AddDecl.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def wasOriginallyTheorem (env : Environment) (declName : Name) : Bool :=
6868
getOriginalConstKind? env declName |>.map (· matches .thm) |>.getD false
6969

7070
/-- If `warn.sorry` is set to true, then, so long as the message log does not already have any errors,
71-
declarations with `sorryAx` generate the "declaration uses 'sorry'" warning. -/
71+
declarations with `sorryAx` generate the "declaration uses `sorry`" warning. -/
7272
register_builtin_option warn.sorry : Bool := {
7373
defValue := true
7474
descr := "warn about uses of `sorry` in declarations added to the environment"
@@ -91,10 +91,10 @@ def warnIfUsesSorry (decl : Declaration) : CoreM Unit := do
9191
-- These can appear without logged errors if `decl` is referring to declarations with elaboration errors;
9292
-- that's where a user should direct their focus.
9393
if let some (_, s) := sorries.find? (·.1) <|> sorries[0]? then
94-
logWarning <| .tagged `hasSorry m!"declaration uses '{s}'"
94+
logWarning <| .tagged `hasSorry m!"declaration uses `{s}`"
9595
else
9696
-- This case should not happen, but it ensures a warning will get logged no matter what.
97-
logWarning <| .tagged `hasSorry m!"declaration uses 'sorry'"
97+
logWarning <| .tagged `hasSorry m!"declaration uses `sorry`"
9898

9999
builtin_initialize
100100
registerTraceClass `addDecl

src/Lean/Class.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def addClass (env : Environment) (clsName : Name) : Except MessageData Environme
159159
let some decl := env.find? clsName
160160
| throw m!"unknown declaration '{clsName}'"
161161
unless decl matches .inductInfo .. | .axiomInfo .. do
162-
throw m!"invalid 'class', declaration '{.ofConstName clsName}' must be inductive datatype, structure, or constant"
162+
throw m!"invalid `class`, declaration '{.ofConstName clsName}' must be inductive datatype, structure, or constant"
163163
let outParams ← checkOutParam 0 #[] #[] decl.type
164164
return classExtension.addEntry env { name := clsName, outParams }
165165

src/Lean/Compiler/CSimpAttr.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def add (declName : Name) (kind : AttributeKind) : CoreM Unit := do
5050
if let some entry ← isConstantReplacement? declName then
5151
ext.add entry kind
5252
else
53-
throwError "invalid 'csimp' theorem, only constant replacement theorems (e.g., `@f = @g`) are currently supported."
53+
throwError "invalid `csimp` theorem, only constant replacement theorems (e.g., `@f = @g`) are currently supported."
5454

5555
/--
5656
Tags compiler simplification theorems, which allow one value to be replaced by another equal value

src/Lean/Compiler/IR/Checker.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def markJP (j : JoinPointId) : M Unit :=
5757
def getDecl (c : Name) : M Decl := do
5858
let ctx ← read
5959
match findEnvDecl' (← getEnv) c ctx.decls with
60-
| none => throwCheckerError s!"depends on declaration '{c}', which has no executable code; consider marking definition as 'noncomputable'"
60+
| none => throwCheckerError s!"depends on declaration `{c}`, which has no executable code; consider marking definition as `noncomputable`"
6161
| some d => pure d
6262

6363
def checkVar (x : VarId) : M Unit := do

src/Lean/Compiler/IR/EmitLLVM.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ def emitSSet (builder : LLVM.Builder llvmctx) (x : VarId) (n : Nat) (offset : Na
10671067
| IRType.uint16 => pure ("lean_ctor_set_uint16", ← LLVM.i16Type llvmctx)
10681068
| IRType.uint32 => pure ("lean_ctor_set_uint32", ← LLVM.i32Type llvmctx)
10691069
| IRType.uint64 => pure ("lean_ctor_set_uint64", ← LLVM.i64Type llvmctx)
1070-
| _ => throw s!"invalid type for 'lean_ctor_set': '{t}'"
1070+
| _ => throw s!"invalid type for `lean_ctor_set`: `{t}`"
10711071
let argtys := #[ ← LLVM.voidPtrType llvmctx, ← LLVM.unsignedType llvmctx, setty]
10721072
let retty ← LLVM.voidType llvmctx
10731073
let fn ← getOrCreateFunctionPrototype (← getLLVMModule) retty fnName argtys
@@ -1489,9 +1489,9 @@ def emitMainFn (mod : LLVM.Module llvmctx) (builder : LLVM.Builder llvmctx) : M
14891489
let d ← getDecl `main
14901490
let xs ← match d with
14911491
| .fdecl (xs := xs) .. => pure xs
1492-
| _ => throw "Function declaration expected for 'main'"
1492+
| _ => throw "Function declaration expected for `main`"
14931493

1494-
unless xs.size == 2 || xs.size == 1 do throw s!"Invalid main function, main expected to have '2' or '1' arguments, found '{xs.size}' arguments"
1494+
unless xs.size == 2 || xs.size == 1 do throw s!"Invalid main function, main expected to have `2` or `1` arguments, found `{xs.size}` arguments"
14951495
let env ← getEnv
14961496
let usesLeanAPI := usesModuleFrom env `Lean
14971497
let mainTy ← LLVM.functionType (← LLVM.i64Type llvmctx)

src/Lean/Compiler/LCNF/ToMono.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def Param.toMono (param : Param) : ToMonoM Param := do
2626
param.update (← toMonoType param.type)
2727

2828
def throwNoncomputableError {α : Type} (declName : Name) : ToMonoM α :=
29-
throwNamedError lean.dependsOnNoncomputable m!"failed to compile definition, consider marking it as 'noncomputable' because it depends on '{.ofConstName declName}', which is 'noncomputable'"
29+
throwNamedError lean.dependsOnNoncomputable m!"failed to compile definition, consider marking it as `noncomputable` because it depends on '{.ofConstName declName}', which is `noncomputable`"
3030

3131
def checkFVarUse (fvarId : FVarId) : ToMonoM Unit := do
3232
if let some declName := (← get).noncomputableVars.get? fvarId then

src/Lean/Data/Json/FromToJson/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected def _root_.Float.fromJson? : Json → Except String Float
191191
| (Json.str "-Infinity") => Except.ok (-1.0 / 0.0)
192192
| (Json.str "NaN") => Except.ok (0.0 / 0.0)
193193
| (Json.num jn) => Except.ok jn.toFloat
194-
| _ => Except.error "Expected a number or a string 'Infinity', '-Infinity', 'NaN'."
194+
| _ => Except.error "Expected a number or a string `Infinity`, `-Infinity`, `NaN`."
195195

196196
instance : FromJson Float where
197197
fromJson? := Float.fromJson?

src/Lean/DocString/Parser.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private partial def atLeastAux (n : Nat) (p : ParserFn) : ParserFn := fun c s =>
2525
if s.hasError then
2626
return if iniPos == s.pos && n == 0 then s.restore iniSz iniPos else s
2727
if iniPos == s.pos then
28-
return s.mkUnexpectedError "invalid 'atLeast' parser combinator application, parser did not consume anything"
28+
return s.mkUnexpectedError "invalid `atLeast` parser combinator application, parser did not consume anything"
2929
if s.stackSize > iniSz + 1 then
3030
s := s.mkNode nullKind iniSz
3131
atLeastAux (n - 1) p c s
@@ -64,7 +64,7 @@ private partial def atMostAux (n : Nat) (p : ParserFn) (msg : String) : ParserFn
6464
if s.hasError then
6565
return if iniPos == s.pos then s.restore iniSz iniPos else s
6666
if iniPos == s.pos then
67-
return s.mkUnexpectedError "invalid 'atMost' parser combinator application, parser did not \
67+
return s.mkUnexpectedError "invalid `atMost` parser combinator application, parser did not \
6868
consume anything"
6969
if s.stackSize > iniSz + 1 then
7070
s := s.mkNode nullKind iniSz

src/Lean/Elab/Binders.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ def elabLetDeclAux (id : Syntax) (binders : Array Syntax) (typeStx : Syntax) (va
854854
let valResult ← elabTermEnsuringType valStx type
855855
let valResult ← mkLambdaFVars xs valResult (usedLetOnly := false)
856856
unless (← isDefEq val valResult) do
857-
throwError "unexpected error when elaborating 'let'"
857+
throwError "unexpected error when elaborating `let`"
858858
pure result
859859

860860
structure LetIdDeclView where

src/Lean/Elab/BuiltinCommand.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private partial def elabChoiceAux (cmds : Array Syntax) (i : Nat) : CommandElabM
286286
let `(export $ns ($ids*)) := stx | throwUnsupportedSyntax
287287
let nss ← resolveNamespace ns
288288
let currNamespace ← getCurrNamespace
289-
if nss == [currNamespace] then throwError "invalid 'export', self export"
289+
if nss == [currNamespace] then throwError "invalid `export`, self export"
290290
let mut aliases := #[]
291291
for idStx in ids do
292292
let id := idStx.getId
@@ -515,7 +515,7 @@ open Lean.Parser.Command.InternalSyntax in
515515
| `($doc:docComment add_decl_doc $id) =>
516516
let declName ← liftCoreM <| realizeGlobalConstNoOverloadWithInfo id
517517
unless ((← getEnv).getModuleIdxFor? declName).isNone do
518-
throwError "invalid 'add_decl_doc', declaration is in an imported module"
518+
throwError "invalid `add_decl_doc`, declaration is in an imported module"
519519
if let .none ← findDeclarationRangesCore? declName then
520520
-- this is only relevant for declarations added without a declaration range
521521
-- in particular `Quot.mk` et al which are added by `init_quot`
@@ -532,7 +532,7 @@ open Lean.Parser.Command.InternalSyntax in
532532
if let some idx := vars.findIdx? (· == id.getId) then
533533
uids := uids.push sc.varUIds[idx]!
534534
else
535-
throwError "invalid 'include', variable `{id}` has not been declared in the current scope"
535+
throwError "invalid `include`, variable `{id}` has not been declared in the current scope"
536536
modifyScope fun sc => { sc with
537537
includedVars := sc.includedVars ++ uids.toList
538538
omittedVars := sc.omittedVars.filter (!uids.contains ·) }
@@ -571,7 +571,7 @@ open Lean.Parser.Command.InternalSyntax in
571571
omittedVars := omittedVars.push uid
572572
omitsUsed := omitsUsed.set! idx true
573573
else
574-
throwError "invalid 'omit', `{ldecl.userName}` has not been declared in the current scope"
574+
throwError "invalid `omit`, `{ldecl.userName}` has not been declared in the current scope"
575575
for o in omits, used in omitsUsed do
576576
unless used do
577577
throwError "`{o}` did not match any variables in the current scope"
@@ -592,10 +592,10 @@ open Lean.Parser.Command.InternalSyntax in
592592
logInfo m!"Lean {Lean.versionString}\nTarget: {target}{String.join platforms}"
593593

594594
@[builtin_command_elab Parser.Command.exit] def elabExit : CommandElab := fun _ =>
595-
logWarning "using 'exit' to interrupt Lean"
595+
logWarning "using `exit` to interrupt Lean"
596596

597597
@[builtin_command_elab Parser.Command.import] def elabImport : CommandElab := fun _ =>
598-
throwError "invalid 'import' command, it must be used in the beginning of the file"
598+
throwError "invalid `import` command, it must be used in the beginning of the file"
599599

600600
@[builtin_command_elab Parser.Command.eoi] def elabEoi : CommandElab := fun _ =>
601601
return

0 commit comments

Comments
 (0)