Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Julia 语法:多个类型声明;宽度“;_Julia - Fatal编程技术网

Julia 语法:多个类型声明;宽度“;

Julia 语法:多个类型声明;宽度“;,julia,Julia,我使用的是julia 0.6,我的代码过去在0.5.2上运行得很好,现在我移植了它,我得到了这个错误 语法:“宽度”的多个类型声明 现在,当我grep-rn“width”*对整个包进行分析时,我得到了这个结果 coolFile.jl:11: local const width::Int64 = Int64(sqrt(modulation)) coolFile.jl:12: local const mapSize::Tuple{Int64, Int64} = (width, width

我使用的是julia 0.6,我的代码过去在0.5.2上运行得很好,现在我移植了它,我得到了这个错误

语法:“宽度”的多个类型声明

现在,当我
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::banana=-69105
写在什么地方了吗?

显然,我所有变量上的
局部常量造成了这个问题。我不知道为什么,但是删除一个说明符(不管是哪个说明符)会导致错误及其无用的错误消息消失

在0.6的发行说明中也没有提到这一点

因为有人否决了我(干得好!否决了一个解决方案)。下面是一个自包含的示例

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

删除
local
const
或类型
::Int64
将导致代码再次工作。

显然,我所有变量上的
local const
导致了问题。我不知道为什么,但是删除一个说明符(不管是哪个说明符)会导致错误及其无用的错误消息消失

在0.6的发行说明中也没有提到这一点

因为有人否决了我(干得好!否决了一个解决方案)。下面是一个自包含的示例

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

删除
local
const
或类型
::Int64
将导致代码再次工作。

是否在同一会话中多次尝试导入coolFile.jl(或其中的函数)?不需要
宽度
后的
::Int64
,类型由
Int64(sqrt(调制)确定)
。错误消息有点不清楚。@AlexanderMorley没有,这不重要,因为它是一个局部变量,作用域在构造函数中。@DanGetz我删除了Int64(…),我同意这是不必要的。仍然是相同的错误消息。很公平。如果没有一个可复制的例子,很难说出其他任何事情。祝你好运!:)您是否在同一会话中多次尝试导入coolFile.jl(或其中的函数)?不需要
宽度后的
::Int64
,类型由
Int64(sqrt(调制))
确定。错误消息有点不清楚。@AlexanderMorley没有,这不重要,因为它是一个局部变量,作用域在构造函数中。@DanGetz我删除了Int64(…),我同意这是不必要的。仍然是相同的错误消息。很公平。如果没有一个可复制的例子,很难说出其他任何事情。祝你好运!:)啊。。因此,删除
::Int64
确实有效。我以为只是在我运行的特定版本上。啊。。因此,删除
::Int64
确实有效。我以为这只是在我运行的特定版本上。