Skip to content

Commit

Permalink
Error on undefined variable in statement position
Browse files Browse the repository at this point in the history
Should fix #6846.
  • Loading branch information
carnaval committed Jan 22, 2016
1 parent 6e88123 commit f14575a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ more than one expression is marked then the same docstring is applied to each ex
:(Base.@__doc__)

function __doc__!(meta, def::Expr)
if isexpr(def, :block, 2) && def.args[1] == symbol("#doc#")
# Convert `Expr(:block, :#doc#, ...)` created by `@__doc__` to an `@doc`.
if isexpr(def, :block, 2) && isexpr(def.args[1], :meta, 1) && def.args[1].args[1] === :doc
# Convert `Expr(:block, Expr(:meta, :doc), ...)` created by `@__doc__` to an `@doc`.
def.head = :macrocall
def.args = [symbol("@doc"), meta, def.args[end]]
true
Expand Down
2 changes: 1 addition & 1 deletion base/docs/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ macro doc(args...)
DocBootstrap._expand_(args...)
end

macro __doc__(ex) esc(Expr(:block, symbol("#doc#"), ex)) end
macro __doc__(ex) esc(Expr(:block, Expr(:meta, :doc), ex)) end

module DocBootstrap

Expand Down
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,7 @@ So far only the second case can actually occur.
(define (compile e break-labels)
(if (or (not (pair? e)) (equal? e '(null)))
;; atom has no effect, but keep symbols for undefined-var checking
#f #;(if (symbol? e) (emit e) #f)
(if (symbol? e) (emit e) #f)
(case (car e)
((call) (emit (goto-form e)))
((=) (let ((vt (vinfo:type
Expand Down
4 changes: 4 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3666,3 +3666,7 @@ f14245() = (v = []; push!(v, length(v)); v)
end
foo9677(x::Array) = invoke(foo9677,(AbstractArray,),x)
@test foo9677(1:5) == foo9677(randn(3))

# issue #6846
f6846() = (please6846; 2)
@test_throws UndefVarError f6846()

0 comments on commit f14575a

Please sign in to comment.