2017-08-11 31 views
1

我使用朱莉婭0.6多類型聲明,用我的代碼在0.5.2就好了,現在我端口運行它,我得到這個錯誤語法:爲「寬度」

syntax: multiple type declarations for "width"

現在,當我grep -rn "width" *對整個包我得到這樣的結果

coolFile.jl:11: local const width::Int64 = Int64(sqrt(modulation)) 
coolFile.jl:12: local const mapSize::Tuple{Int64, Int64} = (width, width) 
coolFile.jl:19:  local const minValue::Float64 = minimumDistance/2 - minimumDistance * width/2 
coolFile.jl:20:  for y in 1:width 
coolFile.jl:22:  for x in 1:width 
coolFile.jl:44:  for i in 1:2:width 
coolFile.jl:45:  local const startIndex = 1 + width*i 
coolFile.jl:46:  inplaceReverse(startIndex:(startIndex + width - 1)) 

我看到的只有一個聲明和寬度的定義。所有這些代碼都在構造函數中。第11行是構造函數體的第一行。我只是瞎了,在某處寫了width::Bananas = -69105

+0

您是否嘗試在同一會話中多次導入coolFile.jl(或其中的函數)? –

+0

不需要'width'後的':: Int64',類型由'Int64(sqrt(modulation))'決定。該錯誤消息有點不清楚。 –

+0

@AlexanderMorley否,它應該沒有關係,因爲它是一個局部變量作用於構造函數。 – Nozdrum

回答

0

顯然我所有的變數local const是造成這個問題。我不知道爲什麼,但刪除一個說明符(無關緊要)會導致無用錯誤消息的錯誤消失。

在0.6的發行說明中也沒有提及任何這方面的內容。

由於有人低估了我(好工作!,downvoting解決方案)。這是一個獨立的例子。

struct Shit 
    a::Int64 
    function Shit(b::Int64) 
     local const c::Int64 = b * 3 
     new(c) 
    end 
end 

ERROR: LoadError: syntax: multiple type declarations for "c" 
Stacktrace: 
[1] include_from_node1(::String) at .\loading.jl:569 
[2] include(::String) at .\sysimg.jl:14 
[3] process_options(::Base.JLOptions) at .\client.jl:305 
[4] _start() at .\client.jl:371 
while loading ~\shit.jl, in expression starting on line 1 

卸下任localconst或類型::Int64將導致再次工作的代碼。

+0

啊..所以刪除':: Int64'確實有效。我認爲這只是在我運行的特定版本上。 –