So I just ran into a super weird bug. I get an "unrecognized name" error for a value which is defined literally the line above where It complains that the unrecongized name is. Plus, it depends on how I use it the next line down.
This compiles fine:
messages = Chat.appendUserMessage previousMessages Stdin.line!
response = Http.send (Chat.buildHttpRequest client messages {}) |> Task.result!
updatedMessages = updateMessagesFromResponse response messages |> Tools.handleToolCalls! client toolHandlerMap
This does not:
messages = Chat.appendUserMessage previousMessages Stdin.line!
updatedMessages = Http.send (Chat.buildHttpRequest client messages {})
|> Task.result!
|> updateMessagesFromResponse messages
|> Tools.handleToolCalls! client toolHandlerMap
Instead I get:
── UNRECOGNIZED NAME in tools.roc ──
Nothing is named `messages` in this scope.
26│ updatedMessages = Http.send (Chat.buildHttpRequest client messages {})
^^^^^^^^
full source here
This could be related to !
desugaring, does it work if you replace Stdin.line!
with a string?
I get the same error when using ?
test : Result Str _
test =
foo = "hello" |> Str.toUtf8
bar =
foo
|> Str.fromUtf8?
|> Str.concat "a"
Ok bar
It only happens in a pipe, if ?
and it is not the last function in the pipe. If you would remove the |> Str.concat "a"
line, it works.
Just a note; I think ?
and !
desugaring share a lot of code
I'll try to get a minimum reproduction tomorrow. For now I did check what happens if I replace the Stdin.line!
with an empty string, and that still produces the same error message.
Last updated: Jul 06 2025 at 12:14 UTC