Strange arithmetic behaviour using structs

I have noticed a strange behaviour when using structs in a simple equation. When I use structs the results of the calculations are wrong, and I cannot really understand why. I have made a minimal example that demonstrates the issue:

struct Env
    L
end

env = Env(2)

t = 4

println("t-env.L+1: ", t-env.L+1)
println("t-(env.L+1): ", t-(env.L+1))

The code above results in the following output:
t-env.L+1: 3
t-(env.L+1): 1

Any clues why this is the case? is it a bug or a feature I just do not understand?

The fact there are structs is irrelevant. 4-2+1 is (4-2)+1 which is 3, and 4-(2+1) is 1.

1 Like

of course…I am such an idiot…I guess I worked too much and my brain is no longer working