Skip to content

Commit

Permalink
Fixes #3547; as call with implicit receiver when invoked as a paramet…
Browse files Browse the repository at this point in the history
…er to a method call
  • Loading branch information
dylandrop authored and asterite committed Dec 12, 2016
1 parent c5e1388 commit 898a7ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Expand Up @@ -1218,6 +1218,14 @@ describe "Parser" do

it_parses "Foo.foo(count: 3).bar { }", Call.new(Call.new("Foo".path, "foo", named_args: [NamedArgument.new("count", 3.int32)]), "bar", block: Block.new)

it_parses %(
class Foo
def bar
print as Foo
end
end
), ClassDef.new("Foo".path, Def.new("bar", body: Call.new(nil, "print", Cast.new(Var.new("self"), "Foo".path))))

assert_syntax_error "a = a", "can't use variable name 'a' inside assignment to variable 'a'"

assert_syntax_error "{{ {{ 1 }} }}", "can't nest macro expressions"
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/parser.cr
Expand Up @@ -3885,7 +3885,7 @@ module Crystal
end

def parse_call_args_space_consumed(check_plus_and_minus = true, allow_curly = false, control = false)
if (@token.keyword?(:as) || @token.keyword?(:end)) && !next_comes_colon_space?
if @token.keyword?(:end) && !next_comes_colon_space?
return nil
end

Expand Down

0 comments on commit 898a7ee

Please sign in to comment.