Closed jrfondren closed 10 months ago
The string module is special because it is actually declared first by the compiler, and when you do require 'string'
a library with extra functions is injected, so I enforced to only allow requiring it from the upper scope.
After commit https://github.com/edubart/nelua-lang/commit/01de5bf1ad8a89300e84e9ce9b3350131f419877 you will get better error messages when attempting to do this.
The related example is the expected behavior, without doing require 'string'
you have a very crude version of string available, this is because the full string library pull lot of stuff, such as allocators and other dependencies. People targeting embedded systems may want to avoid it.
Bug description
I wrote a library with a function-localized
require 'string'
, used that library, and then didn't use the function with the require. The resulting code failed to compile with a C compiler error.Code example
Current behavior
Related example
I ran into another surprising effect from requiring 'string', and also thought it was a bug for a while:
Error:
The easy workaround was to have lua do that:
Non-complaint
That Lua's involved in the compilation process is a strength of Nelua, so I accept that requiring a library can have apparently strange effects like the previous one. Even C compiler errors are reasonable when the library has
## linklib 'does-not-exist'
.Environment
arm64 linux Nelua 0.2.0-dev Build number: 1588 Git date: 2023-09-16 16:20:44 -0300 Git hash: 596fcca5c77932da8a07c249de59a9dff3099495 Semantic version: 0.2.0-dev.1588+596fcca5 Copyright (C) 2019-2022 Eduardo Bart (https://nelua.io/)