Compare commits

...

2 Commits

Author SHA1 Message Date
Scott Morrison
400c8c5e37 add test 2024-02-06 19:47:31 +11:00
Scott Morrison
cfeb957807 fix: don't drop doc-comments on simprocs 2024-02-06 18:57:05 +11:00
2 changed files with 8 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ macro_rules
macro_rules
| `($[$doc?:docComment]? $kind:attrKind simproc $[$pre?]? $[ [ $ids?:ident,* ] ]? $n:ident ($pattern:term) := $body) => do
let mut cmds := #[( `(simproc_decl $n ($pattern) := $body))]
let mut cmds := #[( `($[$doc?:docComment]? simproc_decl $n ($pattern) := $body))]
let pushDefault (cmds : Array (TSyntax `command)) : MacroM (Array (TSyntax `command)) := do
return cmds.push ( `(attribute [$kind simproc $[$pre?]?] $n))
if let some ids := ids? then
@@ -116,13 +116,13 @@ macro_rules
macro_rules
| `($[$doc?:docComment]? $kind:attrKind builtin_simproc $[$pre?]? $n:ident ($pattern:term) := $body) => do
`(builtin_simproc_decl $n ($pattern) := $body
`($[$doc?:docComment]? builtin_simproc_decl $n ($pattern) := $body
attribute [$kind builtin_simproc $[$pre?]?] $n)
| `($[$doc?:docComment]? $kind:attrKind builtin_simproc $[$pre?]? [seval] $n:ident ($pattern:term) := $body) => do
`(builtin_simproc_decl $n ($pattern) := $body
`($[$doc?:docComment]? builtin_simproc_decl $n ($pattern) := $body
attribute [$kind builtin_sevalproc $[$pre?]?] $n)
| `($[$doc?:docComment]? $kind:attrKind builtin_simproc $[$pre?]? [simp, seval] $n:ident ($pattern:term) := $body) => do
`(builtin_simproc_decl $n ($pattern) := $body
`($[$doc?:docComment]? builtin_simproc_decl $n ($pattern) := $body
attribute [$kind builtin_simproc $[$pre?]?] $n
attribute [$kind builtin_sevalproc $[$pre?]?] $n)

View File

@@ -5,11 +5,15 @@ def foo (x : Nat) : Nat :=
open Lean Meta
/-- doc-comment for reduceFoo -/
simproc reduceFoo (foo _) := fun e => do
unless e.isAppOfArity ``foo 1 do return .continue
let some n Nat.fromExpr? e.appArg! | return .continue
return .done { expr := mkNatLit (n+10) }
#eval show MetaM _ from do
guard <| ( findDocString? ( getEnv) ``reduceFoo) = some "doc-comment for reduceFoo "
example : x + foo 2 = 12 + x := by
set_option simprocs false in fail_if_success simp
simp_arith