Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

ERROR: syntax: function argument names not unique #86

Closed
andreasnoack opened this issue Apr 26, 2016 · 10 comments
Closed

ERROR: syntax: function argument names not unique #86

andreasnoack opened this issue Apr 26, 2016 · 10 comments

Comments

@andreasnoack
Copy link

andreasnoack commented Apr 26, 2016

I'm trying to debug the fit function in Lasso.jl. When I try to print a local variable in the function I get the error in the title and Gallium terminates. To reproduce the error try

using Lasso
using Gallium
@enter fit(LassoPath, rand(Float32,10,10), rand(Float32,10), Normal())

then step into all the default arguments (see #85) and, when in the function body, do n until

In /home/andreas/.julia/v0.5/Lasso/src/Lasso.jl:226                                      
239       end                                                                            
240                                                                                      
241       # Lasso initialization                                                         
242       α = convert(T, α)                                                              
243       λminratio = convert(T, λminratio)                                              
244       coefitr = randomize ? RandomCoefficientIterator() : (1:0)                      

About to run: (convert)(Float32,1.0f0)                                                   

1|julia > α                                                                              
ERROR: syntax: function argument names not unique                                        
 in eval(::Expr) at /home/andreas/.julia/v0.5/Lasso/src/Lasso.jl:1                       
 in eval_in_interp(::ASTInterpreter.Interpreter, ::Symbol, ::Symbol, ::UTF8String) at /h$
me/andreas/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1086                         
 in (::ASTInterpreter.##59#65)(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UI$
t8,1}}, ::Bool) at /home/andreas/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1361   
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./Lin$
Edit.jl:1570                                                                             
 [inlined code] from ./LineEdit.jl:18                                                    
 in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/andreas/.julia/v0.5/ASTInterpret$
r/src/ASTInterpreter.jl:1407                                                             
 in eval(::Module, ::Any) at ./boot.jl:236                                               
@Keno
Copy link
Member

Keno commented Apr 26, 2016

@JeffBezanson: There are duplicate slotnames:

Any[symbol("#fit#1"),:wts,:offset,:α,:nλ,:λminratio,:λ,:standardize,:intercept,:naivealgorithm,:dofit,:irls_tol,:randomize,:maxncoef,:fitargs,symbol(""),symbol("#temp#"),:X,:y,:d,:l,:n,:Xnorm,:coefitr,:cd,:autoλ,:off,:mu,:nullb0,:nulldev,:muscratch,:Xy,:model,:nullmodel,:eta,:rr,:path,symbol("#temp#"),symbol("#temp#"),symbol("r#309"),symbol("#temp#"),symbol("i#310"),symbol("n#311"),:i,symbol("i#312"),:i,symbol("r#305"),symbol("#temp#"),symbol("i#306"),symbol("n#307"),:i,symbol("i#308"),:i,symbol("#temp#"),:i,symbol("#temp#"),symbol("#temp#"),symbol("#temp#"),symbol("#temp#"),symbol("#temp#"),symbol("#temp#")]

Is that expected?

@StefanKarpinski
Copy link
Collaborator

Isn't that part of the idea of slots? That the same name can refer to different "slots" at different points in the code?

@JeffBezanson
Copy link
Collaborator

Yes; the slot numbers are what matter now, and the names are just debug info so they don't have to be unique.

@Keno
Copy link
Member

Keno commented Apr 26, 2016

Ok, but then we need code to determine what the currently active set of slots is and only consider those when printing variables or evaluating expressions.

@josefsachsconning
Copy link
Collaborator

We have also encountered this problem at Conning.

@vtjnash
Copy link
Collaborator

vtjnash commented Apr 29, 2016

That the same name can refer to different "slots" at different points in the code?

note that those points in the code can have overlapping lifetimes. the distinguishing characteristic is that they have different slot ids.

@Keno
Copy link
Member

Keno commented Apr 29, 2016

Yes, so the question is which one to use when we are asked to the value of variable x. I'd be inclined to use the one last assigned to a slot with that name. Thoughts?

@JeffBezanson
Copy link
Collaborator

That sounds good. Will probably cover 90% of cases. However I also believe it's orthogonal to this issue, since for example there will often be many variables called #temp# even if the user code doesn't reuse variable names.

@Keno
Copy link
Member

Keno commented Apr 29, 2016

We can remove #temp#.

@Keno
Copy link
Member

Keno commented Apr 29, 2016

I'm implementing that solution, but it's not quite satisfying, e.g. for

function evallet(i)
    j = let i = i+1
        i
    end
    i,j,i+1==j
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants