1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15function f1(a)
16{
17  assert(a === 2)
18  {
19    assert(a() === 1)
20    function a() { return 1 }
21  }
22  assert(a === 2)
23}
24f1(2)
25
26function f2([a])
27{
28  assert(a === 4)
29  {
30    assert(a() === 3)
31    function a() { return 3 }
32  }
33  assert(a === 4)
34}
35f2([4])
36
37function f3(a)
38{
39  assert(a() === 5)
40  {
41    assert(a() === 6)
42    function a() { return 6 }
43  }
44  assert(a() === 5)
45
46  function a() { return 5 }
47}
48f3(7)
49
50function f4(a)
51{
52  assert(a === 8)
53  {
54    eval("function a() { return 9 }")
55    assert(a() === 9)
56  }
57  assert(a() === 9)
58}
59f4(8)
60
61function f5(a, b = function() { return a }) {
62  function a() { return 9 }
63
64  assert(a() === 9)
65  assert(b() === 10)
66}
67f5(10)
68