HeliosLang/compiler

2nd-level import reports errors at 1st-level import's call-site to l2

rjharmon opened this issue · 3 comments

script: import {foo} from foo; ... foo()

foo:

import {bar} from bar;   ...func foo() { 
   ... bar() // "line 42" 
}

bar:

   // ...
   print("hi"); // or error()
   stuff.get("thing-not-found") 

I'm expecting all the issues in bar to be reported at sites in bar, but are reported at foo "line 42" instead. Nothing catastrophic, but for good modularity support...

Do you have the complete output from running this program?

added in private thread

I'm unable to replicate this.

I'm using the following test:

import { Program } from "@hyperionbt/helios";

export default async function test() {
    const program = Program.new(`
    testing nested_modules

    import { foo } from Foo

    func main() -> Bool {
        foo()
    }
    `, [
        `
        module Foo
        
        import { bar } from Bar
        func foo() -> Bool {
            print("foo");
            bar()
        }
        `,
        `module Bar
        
        func bar() -> Bool {
            if (1 == 1) {
                error("bar")
            };
            true
        }`
    ]);

    console.log((await program.compile(false).run([])).toString())
}

test()

The printed output is:

INFO (Foo:6:18) foo
INFO (Bar:5:22) bar
Error: thrown during UPLC evaluation
INFO (Foo:6:18) foo
ERROR (Bar:5:22) bar
TRACE (Bar:4:13)
TRACE (Foo:7:16)
TRACE (nested_modules:7:12)