Fix loading of external modules.

This commit is contained in:
Qi Xiao 2016-02-16 23:24:09 +01:00
parent c37a51c2ed
commit ecaf1b73f9

View File

@ -168,14 +168,14 @@ func compileUse(cp *compiler, fn *parse.Form) Op {
// No filename; defaulting to $datadir/$modname.elv.
dataDir, err := store.DataDir()
maybeThrow(err)
filename = dataDir + modname + ".elv"
filename = dataDir + "/" + modname + ".elv"
if _, err := os.Stat(filename); os.IsNotExist(err) {
// File does not exist. Try loading from the table of builtin
// modules.
filename = "<builtin module>"
var ok bool
if source, ok = builtinModules[modname]; ok {
// Source is loaded. Do nothing more.
filename = "<builtin module>"
} else {
throw(fmt.Errorf("cannot load %s: %s does not exist", modname, filename))
}