Rhai: import and compiling into AST

I have a question: when I compile a script with import into an AST apparently the imported script is not compiled in; consequently, the imported functions are not available... If that expected how do I compile a nested script suite starting from the top?

E.g. the following script:

import "utils" as utils;

fn increment(value) {
    print("script: Incrementing... (increment)");
    utils::trace("incrementing... (trace)");
    value + 1

with utils.rhai as:

fn trace(msg) {
    print("script: " + msg);

produces the following AST:

    source: None,
    statements: [
                Ident("utils" @ 4:30),
    functions: Module(
        functions: increment(value)

Iow: the imported utils module is not compiled in...?

What version of Rhai are you using? I don't know much about it myself, but looking at the release notes, I saw this relevant change in version 0.19.5.

Also, which module resolver are you using?

If you don't find any answers on this forum, you could try posting in their issue tracker on GitHub.

I'm on 0.19.9 with the same result -- using the FileModuleResolver. This seems to contain the answer with a probable solution coming...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.