Skip to content

Commit

Permalink
add lintpragma for short new argument case
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhffong committed Oct 3, 2014
1 parent a3788b9 commit 9aaa480
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ function lintfunctioncall( ex::Expr, ctx::LintContext )
if haskey( ctx.callstack[i].typefields, tname )
fields = ctx.callstack[i].typefields[ tname ]
if 0 < length( ex.args ) - 1 < length( fields )
msg( ctx, 0, "new is provided with fewer arguments than fields." )
if !in( "Ignore short new argument", ctx.callstack[end].pragmas )
msg( ctx, 0, "new is provided with fewer arguments than fields." )
end
elseif length( fields ) < length( ex.args ) - 1
msg( ctx, 2, "new is provided with more arguments than fields" )
end
Expand Down
12 changes: 12 additions & 0 deletions test/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,15 @@ end
"""
msgs = lintstr(s)
@assert( isempty( msgs ) ) # ok
s = """
type MyType
a::Int
b::Int
function MyType( x )
@lintpragma( "Ignore short new argument" )
new(x)
end
end
"""
msgs = lintstr(s)
@assert( isempty( msgs ) )

1 comment on commit 9aaa480

@tonyhffong
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: #38

Please sign in to comment.