temperlang / temper

2 stars 0 forks source link

Support arbitrary imports in repl #2

Open tjpalmer opened 9 months ago

tjpalmer commented 9 months ago

Imports from std work in the repl:

$ let { Date } = import("std/temporal");
interactive#0: void
$ new Date(2023, 9, 19)
interactive#1: {class: Date, year: 2023, month: 9, day: 19}

But arbitrary relative imports still don't:

$ let { Circle } = import("./shape");
1: let { Circle } = import("./shape");
                    ┗━━━━┛
[interactive#2:1+17-23]@G: Expected function type, but got Function
1: let { Circle } = import("./shape
         ┗━━━━┛
[interactive#2:1+6-12]@G: Expected function type, but got Invalid
1: let { Circle } = import("./shape
         ┗━━━━┛
[interactive#2:1+6-12]@G: No member Circle in AnyValue__0
interactive#2: fail

And wildcard imports also fail:

$ let { ... } = import("std/regex");
interactive#0: fail
$ let regex = new Sequence([
        new CodePoints("a"),
        new Capture(name = "thing", item = Dot),
        new CodePoints("c"),
      ]).compiled();
3: e = "thing", item = Dot),
                       ┗━┛
[interactive#1:3+41-44]@G: No declaration for Dot
interactive#1: fail

Or maybe it's just Dot or things like it that fail:

$ let { ... } = import("std/regex");
interactive#32: fail
$ let { Dot } = import("std/regex");
interactive#33: fail
$ let { Regex } = import("std/regex");
interactive#34: void
tjpalmer commented 4 weeks ago

Regex import got fixed:

$ let { ... } = import("std/regex");
interactive#0: void
$ Dot
interactive#1: {class: Dot__13}

But I don't think we supported relative imports yet.