Repository navigation
Compiled analyzers can call interpreter-only builtins (4.2.25) - #780
Merged
Merged
Conversation
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
force-pushed
the
fix/compiled-builtin-bridge
branch
from
October 14, 2026 16:35
1a0a245 to
1d45d25
Compare
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.
Problem. The code generator writes every builtin call as
Arun::<name>(...). A builtin added to the interpreter (Fn::) without a compiledArun::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:arrayreversearrayslicearraysortarrayuniquepushstrindexofstrlastindexofstriscapsstrjoinrematchrefindresubstreadfilereadlinesfileexistsdirexistsdirlistfilesizedeletefileabsrandomintjsonparsejsonwritejsonwritematters most. The KB template'sKBFuncs.nlpcalls 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}):bridgedFnstable inIaction::genEval.fnbridge(newlite/arunbridge.cpp) wraps the evaluated arguments as a temporary action and callsFn::fnCall, exactly asIaction::evaldoes, then frees them the same way.Builtins that do have an
Arun::twin are unchanged.Testing
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).jsonwritethrough the KB template. It builds and runs, and itsoutput.json,final.treeanddatetimes.kbbare identical to the interpreted run, with no errors.-COMPILEANAon 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.-DEVFull 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.
adoptconceptsandmakeparentconceptare 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