Permalink
Browse files

Fix issue #259, return only 1st result from assert

  • Loading branch information...
takikawa committed Dec 6, 2016
1 parent 5888d8d commit 57573dc95fa93cf2a6d5a9dacd34767183f76b99
Showing with 5 additions and 1 deletion.
  1. +4 −1 src/pf/anf.lua
  2. +1 −0 src/pf/backend.lua
@@ -247,7 +247,10 @@ local function renumber(expr)
end
local function lookup(var)
if var == 'len' then return var end
return assert(substs[var], "unbound variable: "..var)
-- NB: assert returns all its arguments on success, and we only
-- want to return the looked up variable here
local subst = assert(substs[var], "unbound variable: "..var)
return subst
end
local function visit(expr)
if type(expr) == 'number' then return expr end
@@ -255,6 +255,7 @@ local function serialize(builder, stmt)
elseif op == 'uint32' then return '('..lhs..' % '.. 2^32 ..')'
end
local rhs = serialize_value(expr[3])
assert(expr[4] == nil) -- sanity check
if op == '[]' then
return read_buffer_word_by_type(builder, 'P', lhs, rhs)
elseif op == '+' then return '('..lhs..' + '..rhs..')'

0 comments on commit 57573dc

Please sign in to comment.