#10 ✓resolved
Jared Kuolt

Tuples are broken when using Eval

Reported by Jared Kuolt | 2008-12-09 13:16:00 UTC

Tuples aren't always responding to their pseudo-methods, yet they're not always failing, either. When assigning a local var as a tuple and calling a method like .size, it results in an error (unknown_receiver). However, performing the same series of steps in a fun works:

$ bin/ire                                                                                                                                                                 Reia Interactive Shell (prerelease)
Running on Erlang (BEAM) emulator version 5.6.3 [source]                                                                                                                  [64-bit] [smp:4] [async-threads:0] [kernel-poll:true]
                                                                                                                                                                          >> (1,2,3).size()   
=> 3                                                                                                                                                                      >> a = (1,2,3)              
=> (1,2,3)                                                                                                                                                                >> a.size()                         
exception throw: {error,unknown_receiver,{1,2,3}}                                                                                                                         in function  reia_dispatch:funcall/3        
in call from reia_erl:erl_funcall/3                                                                                                                                       in call from 'Eval':exprs/2                         
>> size(a)                                                                                                                                                                => 3                                                        
>> a = fun do                                                                                                                                                             ..  (1,2,3).size()                                                  
..                                                                                                                                                                        => #                    
>> a()                                                                                                                                                                    => 3                                                                                
>> a = fun do                                                                                                                                                             ..   b = (1,2,3)                                                                            
..   b.size()                                                                                                                                                             ..                                                                                                  
=> #                                                                                                                  >> a()                                                                                                        
=> 3                                                                                                                                                                      >> b = (1,2,3)                                                                                                          
=> (1,2,3)                                                                                                                                                                >> b.size()                                                                                                                       
exception throw: {error,unknown_receiver,{1,2,3}}                                                                                                                         in function  reia_dispatch:funcall/3                                                                                                      
in call from reia_erl:erl_funcall/3                                                                                                                                       in call from 'Eval':exprs/2                                                                                                                       
>> b = [1,2,3]                                                                                                                                                            => [1,2,3]                                                                                                                                                
>> b.size()
=> 3

Comments and changes to this ticket

  • Tony Arcieri

    Tony Arcieri 2008-12-10 13:53:54 UTC

    • State changed from “new” to “open”

    This is a bug in Reia's Eval implementation. Fixes for it are non-trivial.

  • Tony Arcieri

    Tony Arcieri 2008-12-12 15:02:56 UTC

    • State changed from “open” to “resolved”

    I've added a small shim around erl_eval which should handle correctly translating the bindings to the appropriate format.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Reia a dynamic scripting language for the Erlang virtual machine (BEAM)

People watching this ticket

Referenced by

Pages