HeliosLang / compiler

Helios is a DSL for writing Cardano smart contracts. This library lets you compile Helios scripts and build Cardano transactions.
https://www.hyperion-bt.org/helios-book
BSD 3-Clause "New" or "Revised" License
139 stars 30 forks source link

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

Open rjharmon opened 10 months ago

rjharmon commented 10 months ago

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...

christianschmitz commented 10 months ago

Do you have the complete output from running this program?

rjharmon commented 10 months ago

added in private thread

christianschmitz commented 10 months ago

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)