[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ambiguous syntax
- From: Sven Olsen <sven2718@...>
- Date: Sun, 16 Dec 2012 10:14:00 -0800
I've seen the below quite often (especially when there are lots of verbose arguments)
Well, I can see why the check was removed -- these do look like significant use cases. But maybe there's a way that we could have the best of both worlds? Perhaps a more cautious check would cut down on the number of troublesome false positives, but still have good odds catching ambiguous syntax bugs?
For example, after matching a prefixexp(), it's easy enough to count the number of additional patterns matched before closing the primaryexp(). So, for very little cost, we could keep the 5.1 check in the parser, but only trigger it in cases where we're extending a primary _expression_ that's already a complete function call or table index.
With that type of check,
object:DrawText2d
(
0,
0,
"Hello world",
Color:Create(1,1,1,1),
Align(center, center)
)
parses just fine, but
f()
(g or h)()
still throws an error. Of course, it's still possible to get a false positive, something like:
FunctionObject.new()
(args)
will trigger an error, even though it clearly ought to be parsed as a single statement. But such cases are rare.
Even so, one might want to change the error message -- just to make it clear that the check can be triggered by false positives. Something like:
"dangerous formatting: function call followed by newline followed by '('."
-Sven