lihaoyi/macropy

Proper import scoping for macros

lihaoyi opened this issue · 2 comments

Currently this:

from my_module import macros, ...

just imports everything from that module, and activates all the macros, regardless of what's in the .... This should be changed to

from my_module import macros, mac_a, mac_b

where only the macros which are explicitly listed get activated, while allowing for aliases:

from my_module import macros, long_macro_name as mac

Proper lexical scoping via symbolic execution would be nice, but is probably extremely hard to do

This works now: 9450545

from macropy.core_tests.aliases_macro import macros, e, f as f_new


def run_normal():
    return e % (1 * max(1, 2, 3))

def run_aliased():
    return f_new % (1 * max((1,'2',"3")))

def run_ignored():
    return g % 1123 #TypeError