Skip to content

Type checker: store <var> as <builtin> of ... inside an included file fails inference ('Could not infer type') — follow-on to #547 #551

Description

@logbie

Summary

Follow-on to #547 (fixed in #550). The analyzer half is fixed — a stdlib call inside an included action no longer reports 'X' is not a function. But the type checker still cannot infer the type of a variable that is assigned a builtin-function result inside an included file, and it is fatal:

error[ERROR]: Type error in included file 'mod.wfl': Type error at line 2, column 5: Could not infer type for variable 'full'

Environment

Minimal reproduction

mod.wfl:

define action called h with parameters s:
    store full as wflhash256 of s
    return full
end action

main.wfl:

include from "mod.wfl"
store r as call h with "x"
display "R=" with r

wfl main.wfl

error[ERROR]: Type error in included file 'mod.wfl': Type error at line 2, column 5: Could not infer type for variable 'full'

Also reproduces with parse_json (store p as parse_json of s) and, in my project, string_split, trim, touppercase, wflhash256_with_salt.

What works (scoping the bug)

Case Result
store full as wflhash256 of s in an included file ❌ fatal "Could not infer type"
same line in the main file ✅ works
return substring of (wflhash256 of s) and 0 and 8 (inlined, no named var) in an included file ✅ works
store inner as call some_action with s (action-call result, not builtin) in an included file ✅ works

So it is specifically store <var> as <builtin-call> inside an included file. Inlining the builtin call (no intermediate variable) or storing an action-call result both type-check fine.

Likely cause

The #550 analyzer change taught the semantic analyzer to recognize builtins inside included files, but the type checker doesn't infer builtin return types in the include path — so a variable bound to a builtin result gets Unknown/uninferable and the type checker aborts. It probably needs the same "recognize builtins" treatment the analyzer got, applied to type inference (return-type lookup) for included files.

Impact

Any real shared library that binds a stdlib result to a variable (hashing, JSON parsing, text munging) still can't be included — the program aborts before running. Current workaround is to inline every builtin call or to concatenate sources at build time. With this fixed, include from would finally work for stdlib-using libraries end to end.

Repro test idea

Extending tests/docs_parser_and_include_fixes_test.rs: an included file with store x as wflhash256 of "a" (and a parse_json variant) called from the main program should run and type-check, not abort.

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