Files
janet/test
Pietro Cerutti 5c45e611a8 Extend the scope of truthy if-let bindings to the fal branch
The `if-let` construct - together with the fact that only `nil` and `false` are falsey - is very handy to express monadic chains over maybe/optional values:

```janet
(if-let [resp (make-http-request)       # is nil on failure
         {:status stat :body body} resp # always truthy, binds `stat` and `body`
         check (= 200 stat)             # continue only on 200 OK
         json (json/decode body true)   # is nil on failure
         {:foo foo} json]
  foo)
```

However, none of the bindings are available in the false branch, which
could be helpful to have for error reporting or fallback logic:

```janet
(if-let [resp (make-http-request)
         {:status stat :body body} resp
         check (= 200 stat)
         json (json/decode body true)
         {:foo foo} json]
  foo
  (if (= 401 stat) # unauthorized, refresh the token
    (try-again)
    nil))
```

This PR makes all symbols introduced by the bindings of an `if-let` available in all branches.
2026-08-27 11:36:22 +00:00
..
2026-04-03 08:38:12 -05:00