Skip to content

Commit

Permalink
Require a type between 'new' and '{ ... }'
Browse files Browse the repository at this point in the history
It seems we're simply not using the 'new { ... }' form in
practice.

Addresses #179, but also relevant for #144.
  • Loading branch information
Carl Masak committed Sep 8, 2016
1 parent bf44fc7 commit ceab4c8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion lib/_007/Parser/Syntax.pm
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ grammar _007::Parser::Syntax {
}
token term:object {
[new» <.ws>
[<identifier> <?{ $*runtime.maybe-get-var(~$<identifier>) ~~ Val::Type }> <.ws>]?
<identifier> <?{ $*runtime.maybe-get-var(~$<identifier>) ~~ Val::Type }> <.ws>
]?
'{' ~ '}' <propertylist>
}
Expand Down
14 changes: 0 additions & 14 deletions t/features/objects.t
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,6 @@ use _007::Test;
parses-to $program, $ast, "a `return` inside of a (short-form) method is fine";
}

{
my $program = q:to/./;
my o1 = { name: "James" };
my o2 = new { name: "James" };
say(o1 == o2);
.

outputs
$program,
qq[True\n],
"`new` on object literals without the type is allowed but optional";
}

{
my $program = q:to/./;
f();
Expand Down

0 comments on commit ceab4c8

Please sign in to comment.