Experimental parameter TDZ (it's not "really" achieving TDZ behaviour, but it
was very simple):

parameter_expressions_scope_ gets a reference to its target function scope, and
uses that auxiliary scope for lookup

A few of the cases proposed by oliver work reasonably well here, but not all of
them:

```
# this seems OK
d8> function f(x, y=x) { return y; }
undefined
d8> f()
undefined
d8> f(1)
1

# this seems to violate TDZ?
d8> function f(x=y, y) { return x; }
undefined
d8> f()
undefined
d8> f(undefined, 1)
1

# this seems OK
d8> function f(x, y=function() { return x; }) { return y(); }
undefined
d8> f(1)
1

# this also seems OK
d8> function f(x=function() { return y; }, y) { return x(); }
undefined
d8> f()
undefined
d8> f(undefined, 1)
1

# This seems OK
d8> function f(x=f, f) { return x("!"); }
undefined
d8> f()
(d8):1: TypeError: x is not a function
function f(x=f, f) { return x("!"); }
                            ^
TypeError: x is not a function
    at f ((d8):1:29)
    at (d8):1:1

d8> f(undefined, f)
(d8):1: TypeError: x is not a function
function f(x=f, f) { return x("!"); }
                            ^
TypeError: x is not a function
    at f ((d8):1:29)
    at f ((d8):1:29)
    at (d8):1:14

d8> f(undefined, print)
!
undefined
d8> function f(f, x=f) { return x("!"); }
undefined
d8> f()
(d8):1: TypeError: x is not a function
function f(f, x=f) { return x("!"); }
                            ^
TypeError: x is not a function
    at f ((d8):1:29)
    at (d8):1:1

d8> f(print)
!
undefined
d8> f(undefined, print)
!
undefined

# etc
```

So, there isn't a real TDZ, but the behaviour is mostly what you'd expect
Proper TDZ seems hard to do without allocating the variables multiple times,
which I'd like to avoid if possible.

(bug in the current impl: tries to set initialized parameters whether they're
allocated or not, so if an initialized variable is totally unused, you get a
problem... should be trivial to fix)

https://codereview.chromium.org/1053773006/

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to