issue #136 allow nil to be assigned

gccjit-ravi534
Dibyendu Majumdar 7 years ago
parent c96483431f
commit e740cc73cc

@ -1565,6 +1565,18 @@ assert(pcall(f, nil))
assert(not pcall(f, 'hello'))
print 'Test 62 OK'
function x()
local f: closure = function() end
f = nil
local f
f = 'a'
return f
end
assert(x() == 'a')
ravi.compile(x)
assert(x() == 'a')
print 'Test 63 OK'
for k,v in pairs(opcodes_coverage)
do
print(k, v)

@ -909,7 +909,7 @@ static void check_valid_store(FuncState *fs, expdesc *var, expdesc *ex) {
var->ravi_type == RAVI_TTABLE ? "table" : (var->ravi_type == RAVI_TARRAYFLT ? "number[]" : "integer[]")));
}
else if (var->ravi_type == RAVI_TSTRING) {
if (ex->ravi_type == var->ravi_type && ex->k != VINDEXED)
if (ex->ravi_type == RAVI_TNIL || ex->ravi_type == var->ravi_type && ex->k != VINDEXED)
return;
luaX_syntaxerror(
fs->ls,
@ -918,7 +918,7 @@ static void check_valid_store(FuncState *fs, expdesc *var, expdesc *ex) {
"Invalid assignment: string expected"));
}
else if (var->ravi_type == RAVI_TFUNCTION) {
if (ex->ravi_type == var->ravi_type && ex->k != VINDEXED)
if (ex->ravi_type == RAVI_TNIL || ex->ravi_type == var->ravi_type && ex->k != VINDEXED)
return;
luaX_syntaxerror(
fs->ls,
@ -927,7 +927,8 @@ static void check_valid_store(FuncState *fs, expdesc *var, expdesc *ex) {
"Invalid assignment: function expected"));
}
else if (var->ravi_type == RAVI_TUSERDATA) {
if (ex->ravi_type == var->ravi_type && var->usertype && var->usertype == ex->usertype && ex->k != VINDEXED)
if (ex->ravi_type == RAVI_TNIL ||
ex->ravi_type == var->ravi_type && var->usertype && var->usertype == ex->usertype && ex->k != VINDEXED)
return;
luaX_syntaxerror(
fs->ls,

Loading…
Cancel
Save