# 😤 Multi-line expressions aren't fully computed

**URL:** <https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599>\
**Category:** General Usage\
**Tags:** gpu, potential-bug, kernelabstractions\
**Created:** [July 10, 2025, 9:30am UTC](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599 "2025-07-10T09:30:24Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [July 10, 2025, 8:30pm UTC](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599/21 "2025-07-10T20:30:30Z")

</div>

> [@giordano](#):
>
> which is executed on its own, but it’s also probably completely elided by the compiler in practice since it doesn’t do anything (it’s not assigned to any variable, it doesn’t have side effects).

One concept of Common Lisp that I somewhat miss in Julia is the concept of compiler hints. In CL if you write some code that the compiler can prove to do nothing (i.e. is removed by dead code elimination) then you get a note from the compiler warning you that it removed some code you wrote. This feature would probably completly eliminate mistakes like OP’s and also be correct in the (contrived) examples where `+ x` actually has side effects.

I think there could be more nice opportunities for compiler hints in Julia. One idea I have would be a way of annotating a function with `@typestable` or something to indicate that you want it to be typestable. In case it is not (for some args), the compiler could write you nice notes explaining why it is not typestable.

Maybe once JuliaLowering.jl is out, one could think about realising compiler hints 🙂

---

<div class="post-metadata">

**Author:** ![\_bernhard](https://avatars.discourse-cdn.com/v4/letter/_/bc79bd/32.png) [@\_bernhard](https://discourse.julialang.org/u/_bernhard)\
**Post date:** [July 10, 2025, 10:12pm UTC](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599/22 "2025-07-10T22:12:07Z")

</div>

> [@abraemer](#):
>
> One idea I have would be a way of annotating a function with `@typestable` or something to indicate that you want it to be typestable.

Although technically not compiler hints, @MilesCranmer’s DispatchDoctor.jl exports the macro `@stable` which goes in that direction.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [July 11, 2025, 7:46am UTC](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599/23 "2025-07-11T07:46:14Z")

</div>

This is a job for a linter. People often default to putting it on the compiler because AOT compilers tend to do this job, too, but we have JIT compilation and it happens distinctly from any syntax errors or warnings. Even our precompilation approaches don’t do anything close to warning us of valid yet suspicious code like `for index in 1:length(array)`, they just cache compiled code. This sort of thing can be handled by a linter option that warns us as we’re writing, and we could turn it off if we’re writing stuff like:

```julia
c = a+b
-c |> mycache

```

Something else to point out, you want the linter option to ignore array literals. Leading `+` aren’t strange in arithmetic expressions, and spaces or newlines between full expressions are very unambiguous separators in matrix syntax.

```julia
julia> [1+20
       +100]
2-element Vector{Int64}:
  21
 100

julia> [1+20+
       100]
1-element Vector{Int64}:
 121

julia> [1+20 +100]
1×2 Matrix{Int64}:
 21 100

julia> [1+20+ 100]
1-element Vector{Int64}:
 121

```

[Previous page](https://discourse.julialang.org/t/multi-line-expressions-arent-fully-computed/130599.md?page=1)
