Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't detect docstring #54

Closed
appleparan opened this issue May 20, 2018 · 1 comment
Closed

can't detect docstring #54

appleparan opened this issue May 20, 2018 · 1 comment

Comments

@appleparan
Copy link

appleparan commented May 20, 2018

julia> versioninfo()
Julia Version 0.7.0-DEV.5036
Commit 9de318afa1* (2018-05-07 18:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, sandybridge)
Environment:
  JULIA_BINDIR = C:\Users\Liam\AppData\Local\Julia-0.7.0-dev\bin
  JULIA_HOME = C:\Users\Liam\AppData\Local\Julia-0.7.0-dev\bin
  JULIA_NUM_THREADS = 4
julia> using Parameters

julia> @with_kw struct Test
       a::Int = 10
       b::Float64 = 1.0
       """
       Test
       """
       function Test(a,b)
           new(10, 20)
       end
       end
ERROR: LoadError: type String has no field head
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at .\sysimg.jl:18
 [2] next(::Parameters.Lines, ::Int64) at C:\Users\Liam\.julia\v0.7\Parameters\src\Parameters.jl:29
 [3] done(::Parameters.Lines, ::Int64) at C:\Users\Liam\.julia\v0.7\Parameters\src\Parameters.jl:36
 [4] with_kw(::Expr, ::Module, ::Bool) at C:\Users\Liam\.julia\v0.7\Parameters\src\Parameters.jl:257
 [5] @with_kw(::LineNumberNode, ::Module, ::Any) at C:\Users\Liam\.julia\v0.7\Parameters\src\Parameters.jl:500
in expression starting at REPL[3]:1

if ( lns.block.args[i] isa Symbol
|| lns.block.args[i] isa String # doc-string
|| !(lns.block.args[i].head==:line))
return lns.block.args[i], i+1
end

Error shows that lns.block.args[i] is a String, and that's why Julia complains about field head. From my understanding, evaluation of if conditions stops when the condition matches, so when matches lns.block.args[i] isa String it is enough. However, it seems Julia also evaluate next line(!(lns.block.args[i].head==:line)) ).

@mauro3
Copy link
Owner

mauro3 commented May 20, 2018

This works on Master since last week ;-) (Note though that your example also runs into JuliaLang/julia#27091)

So, I'll close. Feel free to re-open if you feel it's not resolved. I'm currently working on some other stuff, so unless it is urgent for you, I'll wait to tag a new version for a bit.

@mauro3 mauro3 closed this as completed May 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants