Ticket #174 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Builtins: Function.toString() can't yield a FunctionDeclaration

Reported by: lth Assigned to: anonymous
Type: defect Priority: major
Milestone: Component: Spec
Version: 4 Keywords:
Cc: brendan,jeffdyer

Description

The ES3 spec states that the toString method on Function must yield a string that has the syntax of FunctionDeclaration. This makes little sense for functions that are anonymous, and in fact may lead to subtle bugs if an implementation chooses to give anonymous functions a name referenced from the body of the function, so that if the function is evaluated to place it into an environment, it will reference its own value instead of a value in the environment.

The spec should either (a) say that other syntaxen are allowed or (b) define the name that will be chosen for anonymous functions.

(FF2, Opera9, and Safari2 all print the function without a name, ie, as a FunctionExpression?, so this is probably the desired behavior.)

Attachments

Change History

Changed 1 year ago by lth

  • status changed from new to closed
  • resolution set to fixed

Based on the implementation evidence and peripheral discussion in email threads not recorded here, I will close this by changing the spec to say that FunctionExpression? is allowed too. The implication is that expression closure syntax will be allowed as well. Reopen this if you think that's a problem.

Note: See TracTickets for help on using tickets.