Function inside if statement?

Mike Wilson mikewse at
Wed Feb 6 00:55:37 PST 2008

Sorry if this was already covered by your summary, but I can confirm
  if (true) function f() {}
yields a SyntaxError in Safari 2.0.4, while
  if (true) { function f() {} }
works fine.

Best regards

> -----Original Message-----
> From: es4-discuss-bounces at 
> [mailto:es4-discuss-bounces at] On Behalf Of liorean
> Sent: den 6 februari 2008 01:42
> To: es4-discuss at
> Subject: Re: Function inside if statement?
> Just wanted to point out the thread starting here:
> <uri:
> /000483.html>.
> It discusses this issue. Brendan gave this answer, a few replies in:
> > Since this is an ES3 extension, allowed by chapter 16, we could
> > codify the majority-share practice, except that it sucks. We have so
> > far avoided specifying function statements, preferring to leave them
> > to implementations to experiment with, on into the ES4 future.
> I did a summary of what the engines did in various browsers at:
> <uri:
> /000495.html>
> The discussion detours a bit after that.
> Also, Microsoft included these tests as section 2.9 in their "JScript
> Deviations from ES3" document at:
> <uri:
> %3Aresources&cache=cache&media=resources:jscriptdeviationsfromes3.pdf>
> Note that the reason Safari according to that document doesn't give
> any results is that the test uses plain function declarations in the
> statement bodies. If the statement bodies had been wrapped in a
> statement list (curlies) then Safari would have given a profile very
> similar to that of Firefox except for the
> break-within-labelled-statement case, IIRC.
> In other words, to do a full set of tests one need to try both the
> statement-list wrapped versions and the plain function declaration
> versions, because they may have differing results.
> -- 
> David "liorean" Andersson
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at

More information about the Es4-discuss mailing list