Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Manual/BasicTypes/Fin.lean
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ numerals are polymorphic in Lean, but the numeral `0` cannot be used in a contex
Fin 0
due to the absence of the instance above

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

```lean (error := true) (name := finK)
Expand All @@ -115,7 +115,7 @@ numerals are polymorphic in Lean, but the numeral `0` cannot be used in a contex
Fin k
due to the absence of the instance above

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

:::
Expand Down
2 changes: 1 addition & 1 deletion Manual/BasicTypes/Sum.lean
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ example : Nat ⊕ String := panic! "Cant' find it"
failed to synthesize
Inhabited (Nat ⊕ String)

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

The desired instance can be made available to instance synthesis using {keywordOf Lean.Parser.Term.have}`have`:
Expand Down
23 changes: 14 additions & 9 deletions Manual/BuildTools/Lake/Config.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Author: David Thrane Christiansen
import VersoManual

import Lean.Parser.Command
import Lake.DSL.Syntax
import Lake.Config.Monad
import Lake.DSL

import Manual.Meta
import Manual.BuildTools.Lake.CLI
Expand Down Expand Up @@ -179,7 +179,8 @@ name = "example-package"
license := "",
licenseFiles := #[FilePath.mk "LICENSE"],
readmeFile := FilePath.mk "README.md",
reservoir := true},
reservoir := true,
enableArtifactCache := false},
configFile := FilePath.mk "lakefile",
relConfigFile := FilePath.mk "lakefile",
relManifestFile := FilePath.mk "lake-manifest.json",
Expand All @@ -194,7 +195,8 @@ name = "example-package"
postUpdateHooks := #[],
buildArchive := ELIDED,
testDriver := "",
lintDriver := ""}
lintDriver := "",
cacheRef? := none}
```
::::
:::::
Expand Down Expand Up @@ -258,7 +260,8 @@ name = "Sorting"
license := "",
licenseFiles := #[FilePath.mk "LICENSE"],
readmeFile := FilePath.mk "README.md",
reservoir := true},
reservoir := true,
enableArtifactCache := false},
configFile := FilePath.mk "lakefile",
relConfigFile := FilePath.mk "lakefile",
relManifestFile := FilePath.mk "lake-manifest.json",
Expand Down Expand Up @@ -341,7 +344,8 @@ name = "Sorting"
postUpdateHooks := #[],
buildArchive := ELIDED,
testDriver := "",
lintDriver := ""}
lintDriver := "",
cacheRef? := none}
```
::::
:::::
Expand Down Expand Up @@ -796,13 +800,14 @@ from git $t $[@ $t]? $[/ $t]?

## Targets

{tech}[Targets] are typically added to the set of default targets by applying the `default_target` attribute, rather than by explicitly listing them.


{tech}[Targets] are typically added to the set of default targets by applying the `default_target` attribute, rather than by explicitly listing them.
:::TODO
It's presently impossible to import Lake.DSL.AttributesCore due to initialization changes, so `default_target` can't be rendered/checked as an attribute above. This should be fixed upstream.
Fix `default_target` above - it's not working on CI, but it is working locally, with the `attr` role.
:::

:::syntax attr (title := "Specifying Default Targets") (label := "attribute")
:::syntax attr (title := "Specifying Default Targets") (label := "attribute") (namespace := Lake.DSL)

```grammar
default_target
Expand Down Expand Up @@ -1019,7 +1024,7 @@ Whitespace is not permitted between the name and `.*` or `.+`.



{docstring Lake.LeanOption (allowMissing := true)}
{docstring Lake.LeanOption}

{docstring Lake.Backend}

Expand Down
5 changes: 3 additions & 2 deletions Manual/Classes.lean
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def f [n : Nat] : n = n := rfl
```leanOutput notClass
invalid binder annotation, type is not a class instance
Nat
use the command `set_option checkBinderAnnotations false` to disable the check

Note: Use the command `set_option checkBinderAnnotations false` to disable the check
```

:::
Expand Down Expand Up @@ -369,7 +370,7 @@ However, {name}`plusTimes2` fails, because there is no {lean}`AddMul' Nat` insta
failed to synthesize
AddMul' ?m.22

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
Declaring an very general instance takes care of the problem for {lean}`Nat` and every other type:
```lean (name := plusTimes2b)
Expand Down
2 changes: 1 addition & 1 deletion Manual/Classes/BasicClasses.lean
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ example (f g : Nat → Nat) : Decidable (f = g) := inferInstance
failed to synthesize
Decidable (f = g)

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

Opening `Classical` makes every proposition decidable; however, declarations and examples that use this fact must be marked {keywordOf Lean.Parser.Command.declaration}`noncomputable` to indicate that code should not be generated for them.
Expand Down
6 changes: 3 additions & 3 deletions Manual/Classes/InstanceDecls.lean
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ with errors in both the left and right recursive calls that read:
failed to synthesize
BEq NatTree

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
Given a suitable recursive function, such as {lean}`NatTree.beq`:
```lean
Expand Down Expand Up @@ -187,7 +187,7 @@ def NatRoseTree.beq : (tree1 tree2 : NatRoseTree) → Bool
failed to synthesize
BEq (Array NatRoseTree)

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

To solve this, a local {lean}`BEq NatRoseTree` instance may be `let`-bound:
Expand Down Expand Up @@ -265,7 +265,7 @@ instance : DecidableEq StringList
failed to synthesize
Decidable (t1 = t2)

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
However, because it is an ordinary Lean function, it can recursively refer to its own explicitly-provided name:
```lean
Expand Down
2 changes: 1 addition & 1 deletion Manual/Classes/InstanceSynth.lean
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Because instance synthesis selects the most recently defined instance, the follo
failed to synthesize
OneSmaller (Option Bool) Bool

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
The {lean}`OneSmaller (Option Bool) (Option Unit)` instance was selected during instance synthesis, without regard to the supplied value of `β`.
:::
Expand Down
6 changes: 3 additions & 3 deletions Manual/Coercions.lean
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end
#check Int.bdiv

/--
error: invalid field 'bdiv', the environment does not contain 'Nat.bdiv'
error: Invalid field `bdiv`: The environment does not contain `Nat.bdiv`
n
has type
Nat
Expand All @@ -122,7 +122,7 @@ The coercion from {lean}`Nat` to {lean}`Int` is not considered when looking up t
example (n : Nat) := n.bdiv 2
```
```leanOutput natBdiv
invalid field 'bdiv', the environment does not contain 'Nat.bdiv'
Invalid field `bdiv`: The environment does not contain `Nat.bdiv`
n
has type
Nat
Expand Down Expand Up @@ -221,7 +221,7 @@ numerals are polymorphic in Lean, but the numeral `9` cannot be used in a contex
Bin
due to the absence of the instance above

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
This is because coercions are inserted in response to mismatched types, but a failure to synthesize an {name}`OfNat` instance is not a type mismatch.

Expand Down
3 changes: 2 additions & 1 deletion Manual/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ def select (choices : α × α × α) : Asnwer → α
```
The resulting error message states that the argument's type is not a constant, so dot notation cannot be used in the pattern:
```leanOutput asnwer
invalid dotted identifier notation, expected type is not of the form (... → C ...) where C is a constant
Invalid dotted identifier notation: The expected type of `.yes`
Asnwer
is not of the form `C ...` or `... → C ...` where C is a constant
```
This is because the signature is:
```signature
Expand Down
1 change: 1 addition & 0 deletions Manual/ErrorExplanations.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Manual
set_option pp.rawOnError true
set_option guard_msgs.diff true

set_option manual.requireErrorExplanations false

inline_extension Inline.errorExplanationLink (errorName : Name) where
data := toJson errorName
Expand Down
2 changes: 1 addition & 1 deletion Manual/Interaction.lean
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Attempting to add a string to a natural number fails, as expected:
failed to synthesize
HAdd String Nat ?m.32

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
Nonetheless, a partially-elaborated term is available:
```leanOutput oneOne
Expand Down
4 changes: 3 additions & 1 deletion Manual/Language/InductiveTypes.lean
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ example : OddList String := .cons "x" (.cons "y" (.cons "z" .nil))
example : OddList String := .cons "x" (.cons "y" .nil)
```
```leanOutput evenOddMut
invalid dotted identifier notation, unknown identifier `OddList.nil` from expected type
Unknown identifier `OddList.nil`

Note: Inferred this identifier from the expected type of `.nil`:
OddList String
```
:::
Expand Down
10 changes: 9 additions & 1 deletion Manual/Meta/ErrorExplanation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ set_option guard_msgs.diff true

namespace Manual

register_option manual.requireErrorExplanations : Bool := {
defValue := true,
descr := "Whether to fail or warn when error explanations don't match. Must be `true` for releases."
}

/-- Loads the JSON data file for the preprocessed MWE code block `name`. -/
def loadPreprocessedMWE (name : Name) (contents : String)
: MetaM (Highlighted × Array (MessageSeverity × String)) := do
Expand Down Expand Up @@ -241,7 +246,10 @@ def tryElabErrorExplanationCodeBlock (errorName : Name) (errorSev : MessageSever
let kindStr := kind?.map (s!" ({·} example)") |>.getD ""
-- Log rather than throw so we can detect all invalid outputs in a
-- single build
logErrorAt ref m!"Invalid output for {(← read).name} code block \
let logFailure :=
if manual.requireErrorExplanations.get (← getOptions) then logErrorAt
else logWarningAt
logFailure ref m!"Invalid output for {(← read).name} code block \
#{codeBlockIdx}{kindStr}: {msg}"
pure #[← ``(Verso.Doc.Block.code "<invalid output>")]
| e@(.internal ..) => throw e
Expand Down
19 changes: 19 additions & 0 deletions Manual/Meta/LakeToml.lean
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,32 @@ instance : Test (Lake.ConfigType kind pkg name) where
| .anonymous => fun (x : Lake.OpaqueTargetConfig pkg name) => Test.toString x
| _ => fun _ => "Impossible!"

instance : Test Lake.CacheRef where
toString _ := "#<cacheref>"

private def contains (fmt : Format) (c : Char) : Bool :=
match fmt with
| .text s => s.contains c
| .tag _ x | .group x .. | .nest _ x => contains x c
| .append x y => contains x c || contains y c
| .align .. | .line | .nil => false

instance [Test α] : Test (Option α) where
toString
| none => "none"
| some x =>
let s := Test.toString x
let s := if contains s '(' || contains s ' ' then "(" ++ s ++ ")" else s
s!"some " ++ s

deriving instance Test for Lake.ConfigDecl
deriving instance Test for Lake.PConfigDecl
deriving instance Test for Lake.NConfigDecl

deriving instance Test for Lake.Package



open Lake Toml in
def report [Monad m] [Lean.MonadLog m] [MonadFileMap m] [Test α] (val : α) (errs : Array DecodeError) : m String := do
let mut result := ""
Expand Down
2 changes: 1 addition & 1 deletion Manual/Monads/Lift.lean
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def getBytes' (input : Array Nat) :
failed to synthesize
MonadStateOf (Array String) (Except String)

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

Because {name}`StateT` has a {name}`MonadControl` instance, {name}`control` can be used instead of {name}`liftM`.
Expand Down
2 changes: 1 addition & 1 deletion Manual/Monads/Zoo.lean
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Only the outermost may be used, because the type of the state is an output param
failed to synthesize
MonadState String M

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

Providing the state type explicitly using {name}`getThe` from {name}`MonadStateOf` allows both states to be read.
Expand Down
3 changes: 2 additions & 1 deletion Manual/Namespaces.lean
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ automatically included section variable(s) unused in theorem 'p_all':
pFifteen
consider restructuring your `variable` declarations so that the variables are not in scope or explicitly omit them:
omit pFifteen in theorem ...
note: this linter can be disabled with `set_option linter.unusedSectionVars false`

Note: This linter can be disabled with `set_option linter.unusedSectionVars false`
```

This can be avoided by using {keywordOf Lean.Parser.Command.omit}`omit`to remove {lean}`pFifteen`:
Expand Down
2 changes: 1 addition & 1 deletion Manual/NotationsMacros/Elab.lean
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ numerals are polymorphic in Lean, but the numeral `5` cannot be used in a contex
Int → Int
due to the absence of the instance above

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

:::
Expand Down
6 changes: 3 additions & 3 deletions Manual/NotationsMacros/Operators.lean
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ However, because the new operator is not associative, the {tech}[local longest-m
failed to synthesize
HAdd Prop Prop ?m.38

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

:::
Expand All @@ -223,7 +223,7 @@ numerals are polymorphic in Lean, but the numeral `2` cannot be used in a contex
Prop
due to the absence of the instance above

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

The new operator is not associative, so the {tech}[local longest-match rule] means that only {name}`HAdd.hAdd` applies to the three-argument version:
Expand All @@ -234,7 +234,7 @@ The new operator is not associative, so the {tech}[local longest-match rule] mea
failed to synthesize
HAdd Prop Prop ?m.20

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```
:::

Expand Down
4 changes: 2 additions & 2 deletions Manual/RecursiveDefs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ However, {lean}`Clause` is semireducible, so the {inst}`ToString String` instanc
failed to synthesize
ToString Clause

Additional diagnostic information may be available using the `set_option diagnostics true` command.
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.
```

The instance can be explicitly enabled by creating a {lean}`ToString Clause` instance that reduces to the {lean}`ToString String` instance.
Expand Down Expand Up @@ -471,7 +471,7 @@ attribute [irreducible] Sequence
#check let xs : Sequence Nat := .ofList [1,2,3]; xs.reverse
```
```leanOutput irredSeq
invalid field 'reverse', the environment does not contain 'Sequence.reverse'
Invalid field `reverse`: The environment does not contain `Sequence.reverse`
xs
has type
Sequence Nat
Expand Down
Loading