Skip to content

Compiled analyzers can call interpreter-only builtins (4.2.25) - #780

Merged
ddehilster merged 1 commit into
masterfrom
fix/compiled-builtin-bridge
Oct 14, 2026
Merged

ddehilster merged 1 commit into
masterfrom
fix/compiled-builtin-bridge

Conversation

@ddehilster

Copy link
Copy Markdown
Member

Problem. The code generator writes every builtin call as Arun::<name>(...). A builtin added to the interpreter (Fn::) without a compiled Arun:: twin therefore made every compiled analyzer that calls it fail to build (C2039: '<name>': is not a member of 'Arun'). An audit compiled one pass per builtin and found 23 in that state:

Arrays arrayreverse arrayslice arraysort arrayunique push
Strings strindexof strlastindexof striscaps strjoin
Regex rematch refind resubst
Files readfile readlines fileexists direxists dirlist filesize deletefile
Other abs randomint jsonparse jsonwrite

jsonwrite matters most. The KB template's KBFuncs.nlp calls it, so KB-template analyzers such as date-time could not be compiled at all.

Fix. For these builtins the generator now emits Arun::fnbridge(nlppp, "name", {args}):

  • The list is a bridgedFns table in Iaction::genEval.
  • fnbridge (new lite/arunbridge.cpp) wraps the evaluated arguments as a temporary action and calls Fn::fnCall, exactly as Iaction::eval does, then frees them the same way.
  • Compiled and interpreted analyzers therefore run the same code, and nothing is reimplemented.
  • Arguments go in a braced list, which C++ evaluates left to right. That keeps the ordering guarantee the generator already maintains for multi-argument calls.

Builtins that do have an Arun:: twin are unchanged.

Testing

  • New fixture tests/compiled-bridge, one pass per bridged builtin, each printing its result. It now compiles, and the compiled output is identical to the interpreted output (23 lines).
  • I compiled the whole date-time analyzer, which uses jsonwrite through the KB template. It builds and runs, and its output.json, final.tree and datetimes.kbb are identical to the interpreted run, with no errors.
  • New Windows CI step after "Package compile libraries". It runs -COMPILEANA on the fixture, builds it with a checked-in CMake template against the libraries just packaged, runs it with -COMPILED, and diffs the output against the interpreted run. A builtin added later without compiled support now fails CI instead of breaking users' compiled analyzers.
  • All other Windows CI steps (39) pass locally, the -DEV Full English Test output is unchanged, and all 20 analyzers (21 inputs) produce byte-identical output to 4.2.18. The new step only runs in CI, because it needs the packaged compile-libs. I ran its commands by hand locally against my own engine libraries, with identical output.

Note. adoptconcepts and makeparentconcept are in the builtin table, but their implementations are inside #ifdef WORDNET. So in normal builds they're "unknown function" even in the interpreter. They're undocumented; this PR leaves them alone.

Merge after #779. Both bump nlp/main.cpp; this one is 4.2.25.

🤖 Generated with Claude Code

The code generator writes a builtin call as Arun::<name>(...), so a builtin
added to the interpreter (Fn::) without a compiled Arun:: twin made every
compiled analyzer that called it fail to build. 23 were in that state: abs,
arrayreverse/slice/sort/unique, push, strindexof/lastindexof/iscaps/join,
rematch/refind/resubst, readfile/readlines, fileexists/direxists/dirlist,
filesize/deletefile, randomint, jsonparse and jsonwrite -- which the KB
template's KBFuncs.nlp calls, so a KB-template analyzer such as date-time
couldn't be compiled at all.

The generator now emits Arun::fnbridge(nlppp, "name", {args}) for those
(Iaction::genEval, bridgedFns table). fnbridge (new lite/arunbridge.cpp) wraps
the evaluated args as a temporary action and runs Fn::fnCall, as
Iaction::eval does, so compiled and interpreted behave the same and nothing is
reimplemented. A braced list evaluates args left to right.

A new Windows CI step compiles a fixture calling all 23 against the compile
libraries CI just packaged, runs it, and compares with the interpreted run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ddehilster
ddehilster force-pushed the fix/compiled-builtin-bridge branch from 1a0a245 to 1d45d25 Compare October 14, 2026 16:35
@ddehilster
ddehilster merged commit 587ee68 into master Oct 14, 2026
7 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.

1 participant