liquidev / rkgk

(repository moved) Multiplayer canvas tool with programmable brushes!
1 stars 1 forks source link

`let` doesn't seem to be working correctly #78

Closed liquidev closed 2 months ago

liquidev commented 2 months ago
get_color = \radius ->
  rgba 255 0 0 0

splat = \radius ->
  let color = get_color radius
  fill color (circle 0 0 0)

[
  splat 64
  splat 64
]
an exception occurred: 1st argument to `fill` must be a color (rgba)

It's pretty clear from the example that color should be an rgba, but it for some reason isn't. Probably because the let becomes deinitialized too early, or never initialized quite right?

It's weird because if you only call splat once, then it doesn't error out:

get_color = \radius ->
  rgba 255 0 0 0

splat = \radius ->
  let color = get_color radius
  fill color (circle 0 0 0)

[
  splat 64
]
liquidev commented 2 months ago

Excuse the four spaces, but I managed to minify the example further:

f = \_ ->
    let x = 1
    x + x

[
    f ()
    f ()
]