-
-
Couldn't load subscription status.
- Fork 5.7k
Description
Error identified, curly brackets were the source of the problem. Would it be possible to make the source of the error more clear?
FORMER ISSUE DESCRIPTION
The below syntax error message is rather unhelpful. The error is produced on the latest pull (7fa1aea) from the repository, compiled on the relevant machine. The indicated line is not a function call, but rather a defintion. It is possible that the problem is not in that line but in that case there is no line number for the error.
$ ~/Downloads/julia/julia heat.jl
syntax error: assignment in function calls not allowed
in load_now at util.jl:231
in load_now at util.jl:245
in require at util.jl:174
in process_options at client.jl:182
in _start at client.jl:236
at .../heat.jl:3
in load_now at util.jl:231
in load_now at util.jl:245
in require at util.jl:174
in process_options at client.jl:182
in _start at client.jl:236
in load_now at util.jl:256
in require at util.jl:174
in process_options at client.jl:182
in _start at client.jl:236
The code in heat.jl is below, and the content on line 3, the function definition for heat, does not have any have any assignments on than line. It is possible I am overlooking the source of the error, but it would appear that either the line number provided is incorrect, the description of the error is misleading, or it is some error at another point which somehow causes this error to appear.
The same error appears to occur inconsistently for functions of that or similar signature, as of two other test heat transfer models that have a similar design, one fails with the same error with the line number pointing at the same function declaration while the other runs without error. The issue is probably not in the line indicated as if the line is copied from the working file to this one, it still fails.
function heat(T::Array{Float64,1},sigma::Float64,dx::Float64,endT::Float64)
local time::Float64
local flx=Array(Float64,size(T,1)-2)
dt=0.9*(0.5*dx*dx/sigma)
time=0.0
while time<endT
if(dt>endT-time){
dt=endT-time
}
for i=1:size(flx,1)
flx[i]=sigma*dt/(dx*dx)*(T[i]+T[i+2]-2*T[i+1])
end
for i=1:size(flx,1)
T[i+1]+=flx[i]
end
time+=dt
end
return time
end
nX=10
sigma=1.0
dx=0.1
nIter=25
T=ones(Float64,nX+2)
endT=10000.0
for i = 2:nX + 1
T[i]=1.0
end
T[1]=0.0
T[nX+2]=100.0
println("Init:")
for i=2:nX+1
println("[",(i-1.5)*dx,"]:",T[i])
end
time=heat(T,sigma,dx,endT)
println("Final:")
for i=2:nX+1
println("[",(i-1.5)*dx,"]:",T[i])
end