Skip to content

LLM-breakdown of 3 issues when run through nighlies/mctest #389

Closed

Description

@willend

@g5t since ~ last ADR discussion over at McCode, the nightlies and the testsuites report 3 errors for the mcstas-antlr run with 3 new LLM-built instruments:

  • Test_NeXus_comp_par_runtime gives a runtime error
  • Unittest_INHERIT_DIAPHRAGM is not compiled
  • Unittest_JUMP_RELATIVE is not compiled

I put my LLM to work on the outputs and got the below analysis:


All three failures are on the mccode-antlr side, and none comes from our patches. I tested with mccode-antlr 0.33.0, the current PyPI release, against current McCode main. It generates code with the 3.9.2 release runtime, which is what your CI’s antlr setup ends up using. I didn’t touch your checkout.

  1. Unittest_JUMP_RELATIVE: the code generator crashes (reproduced).
    The crash is in mccode_antlr/instr/visitor.py:
def visitJumpPrevious(self, ctx):
    i = ctx.IntegerLiteral()
    return ("PREVIOUS", -1) if i is None else (f"PREVIOUS_{i}", -int(i))   # TypeError

ctx.IntegerLiteral() returns a parse-tree token, not a number, so int(i) fails. visitJumpNext has the same bug. Any JUMP PREVIOUS(n) or JUMP NEXT(n) with an explicit n crashes, while plain JUMP PREVIOUS / NEXT works. The fix is int(i.getText()) in both functions. The later resolution (absolute_target = index + relative_target) is already correct. Separately, there’s no range check, so an out-of-range target isn’t reported as an error, unlike classic McStas after the grammar fixes.

  1. Unittest_INHERIT_DIAPHRAGM: the C doesn’t compile (reproduced).
    The error is redefinition of 'slit_print_if' (and the other slit_* helpers). component_share_declarations() in translators/c_decls.py writes out each component type’s SHARE blocks with no deduplication. Diaphragm inherits Slit’s SHARE, so it’s written once for Slit and again for Diaphragm. Classic McStas emits each SHARE block once, as the grammar-fixes ADR (ADR_20261007_GRAMMAR_FIXES.md) requires. Everything else about the INHERIT works: with the duplicate block deleted by hand, it compiles and gives AfterSlit_I = 0.2497 and AfterDiaphragm_I = 0.0621 (expected 0.25 / 0.0625). The fix is to skip SHARE blocks already emitted, matched by content or source file. The loop also iterates over a set, so the SHARE order isn’t deterministic.

  2. Test_NeXus_comp_par_runtime: runtime error (from reading the code; I couldn’t build with NeXus here).
    mccode-antlr and classic McStas describe component parameters to the runtime differently. The runtime function mcrt_register_param() rebuilds each parameter struct’s layout from the type name passed in each mccomp_param_nexus(...) call. It only understands classic McStas’s names: int, char*, char, MCNUM, double, plus a {...} literal for vectors. mccode-antlr passes something else:

Parameter classic passes mccode-antlr passes Result in runtime
strings (psd.filename, Monitor_nD options, …) "char*" "char *" (with a space) unknown type: the whole component is marked unsupported:unknown-type
{...} vectors (Vertical_Bender rTopPar …) "MCNUM" + "{0.99, …}"; stored as an array in the struct "double*" + "0.99,0.219,…" (no braces); stored as a pointer unknown type, and the struct layout differs too
pointer vectors (conics.radii) "MCNUM" + "&…"/NULL "double*" + "shell_radii" unknown type, so conics.nshells is lost as well

As a result psd, psd_copy, lmon, banana, both benders and conics get no runtime_value. dump_runtime.py then reports failed expectations, and the instrument’s FINALLY calls exit(1), which the test harness reports as a runtime error. I expect the downloaded logs to show unsupported:unknown-type for those components in the h5 file.

This one can be fixed on either side:

mccode-antlr side: emit classic’s type names and literals. The struct also has to store {...} vectors as arrays, otherwise the vector values still can’t be read.
McCode runtime side: have mcrt_register_param() also accept "char " and "double". If it should report the bender vector values, the element count can come from the comma-separated literal and it can read through the pointer.

The first two are clear-cut mccode-antlr bugs; I’d file them on mccode-dev/mccode-antlr.

Activity

  1. g5t commented on Oct 13, 2026

    @g5t
    Collaborator

    Have you checked whether the above issues hold against the main branch? #370 was merged into main to implement your ADR20261007 changes but not released before yesterday in v0.34.0

  2. willend commented on Oct 13, 2026

    @willend
    ContributorAuthor

    just checked via yesterday's 'new-nightlies' - they always install directly off of main using pip (this one then from October 11th 23:00)

    • Test_NeXus_comp_par_runtime indeed now runs as expected
    • Unittest_INHERIT_DIAPHRAGM and Unittest_JUMP_RELATIVE with the above timestamp still don't compile. Will test locally with v0.34.0 for those
  3. willend commented on Oct 13, 2026

    @willend
    ContributorAuthor

    Indeed tested functional with v0.34.0, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions