Skip to content

Commit

Permalink
Throw method error instead of throwing a generic error upon keyword m…
Browse files Browse the repository at this point in the history
…ismatch
  • Loading branch information
dhoegh committed May 30, 2016
1 parent 7e48c5c commit 3ea0a50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ backtrace() = ccall(:jl_backtrace_from_here, Array{Ptr{Void},1}, (Int32,), false
catch_backtrace() = ccall(:jl_get_backtrace, Array{Ptr{Void},1}, ())

## keyword arg lowering generates calls to this ##
kwerr(kw) = error("unrecognized keyword argument \"", kw, "\"")
kwerr(kw, args...) = throw(MethodError(typeof(args[1]).name.mt.kwsorter, (kw,args...)))

## system error handling ##

Expand Down
3 changes: 2 additions & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@
,else)))
(if (null? restkw)
;; if no rest kw, give error for unrecognized
`(call (top kwerr) ,elt)
`(call (top kwerr) ,kw ,@(map arg-name pargl),@(if (null? vararg) '()
(list `(... ,(arg-name (car vararg))))))
;; otherwise add to rest keywords
`(ccall 'jl_cell_1d_push Void (tuple Any Any)
,rkw (tuple ,elt
Expand Down

0 comments on commit 3ea0a50

Please sign in to comment.