You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
closure's input type is inherited from the surrounding block #18564
Hi all! I have seen the new typing system which looks really interesting, and I might have felt on a corner case
Error: nu::parser::operator_unsupported_type
× The '+' operator does not work on values of type 'nothing'.
╭─[/home/.../Documents/server-check.nu:20:20]
19 │ def run_check [server: string, --prev-id: oneof<string, nothing>]: nothing -> oneof<string, nothing> {
20 │ let kb_to_fs = { $in + "kB" | into filesize }
· ─┬─ ┬
· │ ╰── does not support 'nothing'
· ╰── nothing
21 │
╰────
This is a closure inside a function. Replacing the closure by a standalone function fixed the issue but I wanted to report it to check with you if it is the expected behavior.
A few thoughts:
may $in incorrectly refer to run_check's $in which is nothing?
is $in unknown at this point so the parser assumes nothing type? I guess it assumes any type IIUC the release notes.
can it infer a type depending on the usage of the closure? (It is a string coming from a long pipeline so I'm not sure what the parser sees at closure call site)
Activity
enforce-runtime-annotations#18528