# Why won't julia ERROR if a variable is not defined when scheduling?

**URL:** https://discourse.julialang.org/t/why-wont-julia-error-if-a-variable-is-not-defined-when-scheduling/132438
**Category:** New to Julia
**Tags:** question, task
**Created:** [September 16, 2025, 12:27pm UTC](https://discourse.julialang.org/t/why-wont-julia-error-if-a-variable-is-not-defined-when-scheduling/132438 "2025-09-16T12:27:43Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)
#### Post date: [September 16, 2025, 1:37pm UTC](https://discourse.julialang.org/t/why-wont-julia-error-if-a-variable-is-not-defined-when-scheduling/132438/5 "2025-09-16T13:37:16Z")

</div>

There is also the additional point that you’re (sometimes) allowed to reference variables before (in terms of location in code) they are declared, which is not related to multi-threading. E.g.

```julia-repl
julia> function main()
           inc_c() = c += 1 # What is c at this point?
           c = 1
           inc_c()
           println(c)
       end;

julia> main()
2

```

(See also [Is it okay that, in Julia, code that never executes can change the result of programs? - #21 by frankwswang](https://discourse.julialang.org/t/is-it-okay-that-in-julia-code-that-never-executes-can-change-the-result-of-programs/124195/21))

---

_[View the full topic](https://discourse.julialang.org/t/why-wont-julia-error-if-a-variable-is-not-defined-when-scheduling/132438)._
