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

ERROR: type String has no field head #167

Closed
innerlee opened this issue Nov 27, 2016 · 10 comments · Fixed by #179
Closed

ERROR: type String has no field head #167

innerlee opened this issue Nov 27, 2016 · 10 comments · Fixed by #179

Comments

@innerlee
Copy link

julia> using Lint

julia> lintstr("""type love
       who
       "Julia :)"
       love() = "yes"
       end
       """)
ERROR: type String has no field head
 in linttype(::Expr, ::Lint.LintContext) at C:\Users\lizhi\.julia\v0.5\Lint\src\types.jl:99
 in lintexpr(::Expr, ::Lint.LintContext) at C:\Users\lizhi\.julia\v0.5\Lint\src\Lint.jl:228
 in lintstr(::String, ::Lint.LintContext, ::Int64) at C:\Users\lizhi\.julia\v0.5\Lint\src\Lint.jl:151
 in lintstr(::String) at C:\Users\lizhi\.julia\v0.5\Lint\src\Lint.jl:124

This error happens if you want to add some inline doc to the inner constructor. One way to bypass this error:
at https://github.com/tonyhffong/Lint.jl/blob/master/src/types.jl#L99,
before the first use of def.head, add the following code

elseif !(:head in fieldnames(def))
    nothing
@TotalVerb
Copy link
Collaborator

Does this documentation syntax actually work?

@innerlee
Copy link
Author

Oh, that's a good question... 😕 Maybe a good linter message instead of error?

@TotalVerb
Copy link
Collaborator

TotalVerb commented Nov 27, 2016

Yes, I think that's the better approach. As far as I can tell, documenting outer constructors works, while "documenting" inner constructors doesn't seem to do anything.

@galenlynch
Copy link

galenlynch commented Dec 20, 2016

I am having a similar problem with valid documentation string syntax. Type definitions with field documentation seems to cause the same error reported by @innerlee. I first encountered this with the following code:

"""
    ContinuousFile(io::IOStream)
Type for an open continuous file.

# Fields

**`io`** `IOStream` object.

**`nsample`** number of samples in a file.

**`nblock`** number of data blocks in a file.

**`header`** [`OriginalHeader`](@ref) of the current file.
"""
immutable ContinuousFile{T<:Integer, S<:Integer, H<:OriginalHeader}
    "IOStream for open continuous file"
    io::IOStream
    "Number of samples in file"
    nsample::T
    "Number of data blocks in file"
    nblock::S
    "File header"
    header::H
end

But it can also be recreated with simpler REPL examples, e.g.:

julia> lintstr("""
       immutable foo
       "bar field"
       bar::Int
       end
       """)
ERROR: type String has no field head
 in linttype(::Expr, ::Lint.LintContext) at /home/galen/.julia/v0.5/Lint/src/types.jl:99
 in lintexpr(::Expr, ::Lint.LintContext) at /home/galen/.julia/v0.5/Lint/src/Lint.jl:228
 in lintstr(::String, ::Lint.LintContext, ::Int64) at /home/galen/.julia/v0.5/Lint/src/Lint.jl:151
 in lintstr(::String) at /home/galen/.julia/v0.5/Lint/src/Lint.jl:124

@TotalVerb
Copy link
Collaborator

TotalVerb commented Dec 28, 2016

This docstring syntax is not valid docstring syntax as far as I know. But this is nevertheless a bug that should be fixed. Thanks for bringing it to our attention.

@galenlynch
Copy link

galenlynch commented Dec 28, 2016 via email

@TotalVerb
Copy link
Collaborator

@galenlynch How does one access this type of field documentation from the REPL?

@galenlynch
Copy link

You can access it by entering type.field in the help mode. For example:

julia> "A type doc string" type foo
       "a field doc string"
       bar::Int
       end

help?> foo.bar
  a field doc string

@TotalVerb
Copy link
Collaborator

Thanks, this is useful information. This issue is fixed by #179.

@galenlynch
Copy link

Thanks for fixing it!

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

Successfully merging a pull request may close this issue.

3 participants