rune icon indicating copy to clipboard operation
rune copied to clipboard

Importing macros by `use` doesn't work

Open pkolaczk opened this issue 2 years ago • 1 comments

I registered a macro param in crate latte:

        let mut latte_module = Module::with_crate("latte");
        latte_module
            .macro_(&["param"], move |ctx, ts| context::param(ctx, &params, ts))
            .unwrap();

Then I can access that macro in the rune source by using fully qualified name:

const FOO = latte::param!("foo", 100);

However this results in the compile error:

use latte::*;
const FOO = param!("foo", 100);  // not found: param!
use latte::param;
const FOO = param!("foo", 100);  // not found: param!

And the following code causes Rune compiler to fall into an infinite loop:

use ::latte::param;
const FOO = param!("foo", 100);  

pkolaczk avatar Nov 17 '21 11:11 pkolaczk

Well that's not good. Thanks for the report!

This is clearly a bug, but I think you can get through it by using Module::with_item for now instead of the (apparently) under-tested crate resolution it'd use with Module::with_crate.

udoprog avatar Nov 17 '21 13:11 udoprog

It seems like the immediate issue with crate resolution has been fixed (or at least according to my testing). Closing this for now!

udoprog avatar May 25 '23 19:05 udoprog