Closed neilconway closed 13 years ago
Test case:
require "rubygems" require "bud" class JoinTest include Bud state do channel :msg_recv, [:@loc, :recv_id] scratch :deliver_msg, msg_recv.schema table :recv_done_max, [] => [:recv_id] end bootstrap do recv_done_max <= [[-1]] msg_recv <~ [[ip_port, 0]] end bloom do deliver_msg <= (msg_recv * recv_done_max).pairs do |b, m| b if b.recv_id == (m.recv_id + 1) end recv_done_max <+ (deliver_msg * recv_done_max).rights {|k| puts "k = #{k.inspect}, k.recv_id = #{k.recv_id}"; [k.recv_id + 1]} # recv_done_max <+ (deliver_msg * recv_done_max).pairs {|x, k| puts "k = #{k.inspect}, k.recv_id = #{k.recv_id}"; [k.recv_id + 1]} end end j = JoinTest.new j.run_fg
Running the test case yields:
k = [-1], k.recv_id = Exception handling network message (channel 'msg_recv'): Exception during Bud evaluation. Exception: #<NoMethodError: undefined method `+' for nil:NilClass>. Rule: recv_done_max < (+(deliver_msg * recv_done_max).rights do |k| puts("k = #{k.inspect}, k.recv_id = #{k.recv_id}") [(k.recv_id + 1)] end)
If you replace the call to rights() with pairs() (see the commented-out alternative), you instead get the expected output (and no error):
rights()
pairs()
k = [-1], k.recv_id = -1
Test case:
Running the test case yields:
If you replace the call to
rights()
withpairs()
(see the commented-out alternative), you instead get the expected output (and no error):