Skip to content

Commit

Permalink
fix JuliaLang#9134, regression on uninitialized let variable
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 25, 2014
1 parent f0dd6c3 commit b3d467c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2620,8 +2620,7 @@ static Value *emit_var(jl_sym_t *sym, jl_value_t *ty, jl_codectx_t *ctx, bool is
}
assert(jbp == NULL);
if (arg != NULL || // arguments are always defined
!vi.isAssigned ||
(!is_var_closed(sym, ctx) &&
((!is_var_closed(sym, ctx) || !vi.isAssigned) &&
!jl_subtype((jl_value_t*)jl_undef_type, ty, 0))) {
Value *theLoad = builder.CreateLoad(bp, vi.isVolatile);
if (vi.closureidx > -1 && !(vi.isAssigned && vi.isCaptured))
Expand Down
9 changes: 9 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1953,3 +1953,12 @@ end
end

@test I8978.h(4) === 7.0

# issue #9134
function f9134()
ii = zeros(Int32, 1)
let i
ii[1] = i
end
end
@test_throws UndefVarError f9134()

0 comments on commit b3d467c

Please sign in to comment.