# Why is this function valid julia syntax?

**URL:** https://discourse.julialang.org/t/why-is-this-function-valid-julia-syntax/83984
**Category:** General Usage
**Tags:** question
**Created:** [July 9, 2022, 9:36am UTC](https://discourse.julialang.org/t/why-is-this-function-valid-julia-syntax/83984 "2022-07-09T09:36:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lukas.grunwald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lukas.grunwald/32/36708_2.png) [@lukas.grunwald](https://discourse.julialang.org/u/lukas.grunwald)
#### Post date: [July 9, 2022, 9:36am UTC](https://discourse.julialang.org/t/why-is-this-function-valid-julia-syntax/83984/1 "2022-07-09T09:36:22Z")

</div>

The following function is valid julia code (in the sense that there is no parsing error)

```julia
function temp(x::AbstractArray)
    x[1] = 1 +
 return nothing
# This is the same as writing x[1] = 1 + return nothing
end

```

which lowers to

```julia
CodeInfo(
1 ─ return Main.nothing
)

```

I find this very unintuitive and would have expected the code to error instead of lowering to the above expression. Why is `1 + return nothing` valid julia syntax, and why is the assignment statement in this case essentially ignored?

---

<div class="post-metadata">

### Author: ![dfdx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfdx/32/120_2.png) [@dfdx](https://discourse.julialang.org/u/dfdx)
#### Post date: [July 9, 2022, 9:44am UTC](https://discourse.julialang.org/t/why-is-this-function-valid-julia-syntax/83984/2 "2022-07-09T09:44:33Z")

</div>

I guess because:

1. `return ...` is a valid Julia expression, i.e. it can be combined with other expressions. This is very convenient e.g. in REPL.
2. Assignment happens after the `return` and thus is effectively unreachable.
