Repository navigation
Make the calculate_sum sample add its arguments instead of returning "a + b" [patch] - #471
Merged
Merged
Conversation
…"a + b" [patch] The sample in Coder.Cli, the README and docs/design.md built its return value from an AstLeafNode<string>, which every generator writes as a string literal, so the function returned the text "a + b" and its C#/C++/Rust/Go output failed to compile. Build it from a BinaryExpression of two VariableReferences, and regenerate the README's YAML and Python output from the CLI. Coder.Test now references Coder.Cli, and SampleFunctionTests generates the sample in all seven languages, before and after a YAML round-trip, and checks it adds its arguments and never returns a string literal. Fixes #470 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4usw8rudxJevraxAd
docs/design.md takes main's unquoted operator: Add, the same value this branch wrote quoted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5MLAZoAbekPms
|
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.



Fixes #470
What was wrong
The
calculate_sumsample inCoder.Cli, the README anddocs/design.mdbuilt its return value fromAstLeafNode<string>("a + b"). Every generator writes a string leaf as a string literal, so the function returned the text"a + b". Its C#, C++, Rust and Go output failed to compile, and the README's own Python output showedreturn "a + b".Change
Coder.Cli/SampleCLI.cs,README.mdanddocs/design.mdnow build the body asnew BinaryExpression(new VariableReference("a"), BinaryOperator.Add, new VariableReference("b")).return (a + b). Thedebugparameter name the README uses is kept.CoderCLI.CreateSampleFunctionis now public and documented, so the test can build the same sample the CLI prints.Coder.Testnow referencesCoder.Cli.Tests
Coder.Test/Cli/SampleFunctionTests.cs. It generates the sample in all seven languages, both before and after a YAML round-trip, and checks that each output containsa + band no"a + b"string literal. It also checks the exact Python signature andreturn (a + b).AstLeafNode<string>body put back, both tests fail. With the fix, both pass.The issue suggests a C# compile check as optional ("ideally"). I didn't add one: the text checks already catch the string literal in every target.
Generated by Claude Code