#10 ✓resolved
Jared Kuolt

Tuples are broken when using Eval

Reported by Jared Kuolt | December 9th, 2008 @ 01:16 PM

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

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