Repository navigation
A kept function's errors: its own file's name for it, said at the function - #75
Merged
Merged
Conversation
…ction functionName read a node's text through the body being compiled, so a handler written in main.ts and kept by a library (Signal.on stores it in signals.ts) was named by a slice of the library's text at main.ts's offsets: "the function handed to ignal } from \"tri". The name is now read from the file the function is written in, and so is a parameter's. The check that a kept function gives back a number, a boolean, a text, a unit, a function or nothing is now said at the function itself, not where it is kept, which may be a library's line far from the code to change. signals.ts's header showed the very handler that is refused, `(wave) => setResources(…)`; it has braces now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U79fdupFuMLxYQmMJtffPN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while compiling the examples for the new TrigScript library guide (scm-js/scm-js#84).
The bug. A signal handler that gives back an action,
cleared.on((wave) => setResources(P1, "add", wave, "ore")), is refused, which is correct: a kept function can't return an action. But the error came out asThere were two problems:
functionNameread the node's text through the body being compiled (signals.ts) instead of the file the function is written in (main.ts), so it cut the wrong file's text at the right offsets.The fix:
main.ts:4 the function handed to cleared.on is kept as a value, ….signals.ts's header example, which showed exactly the refused form, now uses braces.compiler/generated/stdlib.tswas re-embedded.Checked: a test in
tests/function-values.test.tscovers this;npm run typecheckpasses, andvitest rungives 75 files and 1384 tests passed.A friendlier option, not taken here: accept an expression-bodied arrow whose result is an action wherever the expected type returns
void, treating the action as a statement. That would be a language change.🤖 Generated with Claude Code
https://claude.ai/code/session_01U79fdupFuMLxYQmMJtffPN