1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00
semantic/semantic-python/test/fixtures/3-02-defining-instance-method.py
Patrick Thomson 01b4a23b23 Use rec so functions can refer to themselves in their bodies.
Code like the following kind is legal in Python:

```python
def recursive(a): return recursive
```

This implies that function and class definitions need to use the Core
`rec` construct so that their bodies have an appropriate entry in the scope.
2019-10-16 17:34:43 -04:00

6 lines
251 B
Python

# CHECK-TREE: { Foo <- rec Foo = { identity <- rec identity = \self -> \x -> x; __semantic_prelude.type "Foo" __semantic_prelude.object #record { identity: identity } }; #record { Foo: Foo } }
class Foo():
def identity(self, x):
return x