zenna / Spec.jl

MIT License
4 stars 0 forks source link

Example usage in README is not supported #12

Open SamWitty opened 1 year ago

SamWitty commented 1 year ago

Looking at src/macros.jl, it looks like the @pre and @post macros only support usage of the following form.

f(x::Float64) = x * sqrt(x)
@pre f(x::Float64) = x > 0 "x must be positive"

However, the README includes a diverse set of examples including some where usage of the @pre macro does not specify the name of the argument and omits an =. For example, running the following code block from the README results in a MacroTools pattern matching error.

f(x::Float64) = x * sqrt(x)
@pre f x > 0
ERROR: LoadError: matching non-exhaustive, at #= /Users/sam-basis/Desktop/Research/Spec.jl/src/macros.jl:38 =#
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] transform(key::UInt64, expr::Symbol)
   @ Spec ~/Desktop/Research/Spec.jl/src/macros.jl:39
 [3] var"@pre"(__source__::LineNumberNode, __module__::Module, precond::Any, meta::Any)
   @ Spec ~/Desktop/Research/Spec.jl/src/macros.jl:57
in expression starting at REPL[3]:1