wu-lang/wu

[bug] import still doesn't behave predictably

evolbug opened this issue · 0 comments

When compiling imports should behave by this system:

compile file:       all imports are relative to initial file
compile directory:  all imports are relative to initial directory
build project:      all imports are relative to src/

The resulting require statements should also use . to separate path elements instead of / and should not contain a ./ prefix

project/
    src/
        lib/
            init.wu
            mylib.wu
        main.wu
    wu.toml

Contents:

# main.wu
import lib { mylib }

# init.wu
import mylib { MyType }

# mylib.wu
MyType: struct {}

Building project: ~/project$ wu build
Expected contents:

-- main.wu
local lib = require "lib"
local mylib = lib["mylib"]

-- init.wu
local mylib = require "lib.mylib"

-- mylib.wu
<empty>

Building directory: ~/project$ wu src/lib
Expected contents:

-- init.wu
local mylib = require "mylib"

-- mylib.wu
<empty>

Building file: ~/project$ wu src/lib/init.wu
Expected contents:

-- init.wu
local mylib = require "mylib"

-- mylib.wu
<empty>