Skip to content

Fix undefined nerror (typo for error) on the invalid-@concrete path#41

Merged
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:fix-nerror-typo
Jun 8, 2026
Merged

Fix undefined nerror (typo for error) on the invalid-@concrete path#41
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:fix-nerror-typo

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

JET flagged an undefined binding in src/ConcreteStructs.jl:

src/ConcreteStructs.jl:254: nerror("Invalid usage of @concrete.")

_find_struct_def is supposed to raise a clear error when @concrete is applied to an expression that is neither a :struct definition nor a :macrocall wrapping one. But the fallthrough called nerror, which is undefined — a typo for error. As a result, on that invalid-usage path the macro threw UndefVarError(:nerror) instead of the intended ErrorException("Invalid usage of @concrete."). Existing tests never exercised that path, so the bug stayed latent.

Fix

  • Change nerror( to error( at src/ConcreteStructs.jl:254. nerror is defined nowhere in the package (confirmed via grep), so it really is a typo.

Test

  • Added an "Invalid usage error path" testset in test/runtests.jl that exercises the path via @macroexpand(@concrete x = 1) (an = expression reaches the fallthrough) and asserts:
@test_throws "Invalid usage of @concrete." @macroexpand(@concrete x = 1)

Verified locally on Julia 1.11:

  • Before the fix: the new test FAILS — the thrown message is UndefVarError: \nerror` not defined in `ConcreteStructs``.
  • After the fix: the new test PASSES (ErrorException with the "Invalid usage of @concrete." message), and the full suite is green (40/40).

Ignore until reviewed by @ChrisRackauckas.

`_find_struct_def` fell through to `nerror("Invalid usage of @concrete.")`
when given an expression that is neither a `:struct` definition nor a
`:macrocall` wrapping one. `nerror` is undefined (a typo for `error`), so
this path threw `UndefVarError(:nerror)` instead of the intended clear
`ErrorException`. JET flagged the undefined binding.

Change `nerror` to `error` and add a regression test exercising the
invalid-usage path (`@concrete x = 1`), asserting it now throws an
`ErrorException` with the "Invalid usage of @concrete." message. The test
fails (UndefVarError) before the fix and passes after.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas marked this pull request as ready for review June 8, 2026 11:50
@ChrisRackauckas ChrisRackauckas merged commit f92d066 into SciML:main Jun 8, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants