Conversation
Keyword arguments in a `@model` function signature were parsed and then silently dropped, with only a `@warn`. The body never saw them, so a user writing `@model function m(x; a = 1)` got no `a` and a later `UndefVarError` as the only real signal, and the warning is easy to miss in a noisy REPL. Raise an error at macro expansion instead, consistent with unsupported positional arguments at the call site, and name the offending keyword arguments plus the supported form. BREAKING: `@model` definitions carrying keyword arguments now fail to expand rather than silently ignoring them. Nothing in this repository relied on the old behaviour: no test or doc asserted the warning, and no `@model` signature with keyword arguments exists in `src/`, `test/`, `docs/` or `README.md`. Downstream packages that defined such signatures will need to drop them, but their keyword arguments were never in effect to begin with. Closes #307. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #326 +/- ##
==========================================
+ Coverage 90.72% 90.76% +0.04%
==========================================
Files 16 16
Lines 2263 2264 +1
==========================================
+ Hits 2053 2055 +2
+ Misses 210 209 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #307. This is a breaking change — see below.
Problem
src/model_macro.jl:959-961parsed keyword arguments in a@modelsignature and then ignored them,emitting only a warning:
A user writing
@model function m(x; a = 1)gets noain the body, so the only real signal is alater
UndefVarError— and the warning is easy to lose in REPL output. Unsupported positionalarguments already hard-error at the call site (
model_macro.jl:923), so this was inconsistent.Change
Error at macro expansion, naming the offending keyword arguments and the supported form:
Breaking-change assessment
Nothing in this repository relied on the old behaviour:
@test_logs/@test_warnanywhere in the suite)ms_kwargsis referenced only atmodel_macro.jl:952and:959@model functionsignatures containing;exist acrosssrc/,test/,docs/andREADME.md— all 39@model functionoccurrences in the docs and README are positional-onlyThe risk is downstream (RxInfer.jl and user code). Any such definition will now fail to expand — but
its keyword arguments were never in effect in the first place, so the fix surfaces a pre-existing
silent bug rather than removing working functionality. Worth a breaking version bump; there is no
CHANGELOG in this repo to update.
Tests
New test item in
test/model_macro_tests.jlasserting the error fires for a kwarg-bearing signature,that it names the offending keywords and the supported form, and that positional-only signatures still
expand.
Full suite on Julia 1.12: 259/259 test items, all passing.
🤖 Generated with Claude Code