Skip to content

require should return the loaded module #26

Description

@graue

I've noticed that when calling require from Lua.js, it doesn't return anything. The code inserted into each compiled Lua module is:

G.str['require'] = function (name) {
  lua_require(G, name);
};

Lua's reference manual states that require should return a value:

Once a loader is found, require calls the loader with a single argument, modname. If the loader returns any value, require assigns the returned value to package.loaded[modname]. If the loader returns no value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].

Lua.js isn't doing the bolded part.

I may submit a patch for this if I can figure it out. This is part of my attempt to get the table method of defining a module to work in Lua.js (see #13).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions