1.31 (tried in SPP only)
Description of Bug:
Cannot re-load an API if it contains a bug and compilation of the chunk failed. (Works if you reboot the lua VM instance, however. ie: CTRL-R the Computer.)
Steps to Reproduce Bug:
Create a file to be loaded as an API. Make sure it's got a compile error in it. Example: A file called "testAPI" which contains…
-- Oops! A typo! Expression instead of statement!
test == 3
Now, load it in some other program. ie: os.loadapi ("testAPI")
You'll get the expected error when lua attempts to compile it. (bios:206: [string "testAPI"]:5: '=' expected)
Now go fix your typo!
Try to load it again.
You'll get API testAPI is already being loaded.
Proposed Fix:
Fix that seems obvious is to modify os.loadAPI in bios.lua as such:
if fnAPI then
setfenv( fnAPI, tEnv )
fnAPI()
else
print( err )
tAPIsLoading[sName] = nil
return false
end
Note setting the tAPIsLoading set to nil if there is an error. Tested and it seems to work fine. But I don't know if this would break something else that might rely upon this behavior.