Skip to content

Included files cannot call stdlib functions inside their actions ('X is not a function') #547

Description

@logbie

Summary

Any action defined in a file brought in with include from fails to analyze if its body calls a standard-library function (e.g. touppercase, wflhash256, wflhash256_with_salt, parse_json). The analyzer reports '<fn>' is not a function for the included file, drops the action, and every call site then fails with Undefined action '<action>'. The same action works fine when defined in the calling ("main") file.

This effectively makes include from unusable for real shared libraries, since almost any useful module touches the stdlib (crypto, JSON, text helpers, etc.).

Environment

  • WFL built from source, .build_meta.json: { "year": 26, "month": 6, "build": 5 }
  • Linux, release build (cargo build --release)

Minimal reproduction

mod.wfl:

define action called shout with parameters s:
    return touppercase of s
end action

main.wfl:

include from "mod.wfl"
main loop:
    store g as call shout with "bob"
    display "R=" with g
    break
end loop

Run wfl main.wfl:

error[ERROR]: Undefined action 'shout'
error[ERROR]: Semantic error in included file 'mod.wfl': Semantic error at line 2, column 24: 'touppercase' is not a function

Expected

R=BOB — the included action should be able to call stdlib functions, exactly as it can when defined in the main file.

Control (works)

The identical action defined in the main file works:

store g as touppercase of "bob"
display "R=" with g     // R=BOB

Notes / likely cause

It looks like the semantic analyzer analyzes included files in isolation without the stdlib function registry loaded, so every stdlib call is treated as an undefined function, which then cascades to the action being dropped. Reproduces with touppercase, wflhash256, wflhash256_with_salt, and parse_json; presumably all stdlib functions are affected.

Confirmed from main loop, describe/test blocks, and top-level call sites — all fail the same way. Priming the function at the top level of the main file (store _ as touppercase of "x") before the include does not help.

Impact

Blocks organizing a project into shared modules. Current workaround is to keep every stdlib-using action in the same file that runs it (or concatenate sources at build time), which defeats the purpose of the module system.

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions