ArgCheck.jl icon indicating copy to clipboard operation
ArgCheck.jl copied to clipboard

!function(arg) does not show the value of arg

Open dpinol opened this issue 1 year ago • 2 comments

This

function f(a)
           @check !startswith(a,"o")
end
f("o")

causes this error

ERROR: CheckError: !(startswith(a, "o")) must hold. Got
startswith(a, "o") => true

It would be nice if it could display the contents of a

dpinol avatar Apr 11 '24 12:04 dpinol

Agreed this would be nice. If you want to take a stab at implementing it, that would be cool.

jw3126 avatar Apr 11 '24 14:04 jw3126

As a workaround, one can also add some parenthesis:

julia> using ArgCheck

julia> x = nothing;

julia> @argcheck (!isnothing)(x)
ERROR: ArgumentError: (!isnothing)(x) must hold. Got
x => nothing
Stacktrace:
 [1] throw_check_error(info::Any)
   @ ArgCheck ~/.julia/packages/ArgCheck/CA5vv/src/checks.jl:280
 [2] top-level scope
   @ REPL[6]:1

jw3126 avatar Apr 12 '24 10:04 jw3126