# Cannot read property 'formals' of null

**URL:** <https://discourse.codecombat.com/t/cannot-read-property-formals-of-null/2243>\
**Category:** Bugs\
**Created:** [January 9, 2015, 12:29am UTC](https://discourse.codecombat.com/t/cannot-read-property-formals-of-null/2243 "2015-01-09T00:29:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dideler](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dideler/32/1699_2.png) [@dideler](https://discourse.codecombat.com/u/dideler)\
**Post date:** [January 9, 2015, 12:29am UTC](https://discourse.codecombat.com/t/cannot-read-property-formals-of-null/2243/1 "2015-01-09T00:29:29Z")

</div>

I’m playing sarven-brawl and I’m running into a code error.

```python
loop:
    enemies = self.findEnemies()
    enemy = self.findNearest(enemies)
    if is_soldier(enemy):
        # Assess the threat and take appropriate action

```

The if line is giving the error `Cannot read property 'formals' of null` when `is_soldier(enemy)` is evaluated and `enemy` is `None` (or `null` to be precise).

I’m performing the null check inside `is_soldier()` but it’s never reached because the program crashes before reaching the check.

FWIW, here is my definition of `is_soldier()`. It shouldn’t matter how it’s defined since I believe passing null as an argument is causing the error.

```python
def is_soldier(enemy):
    if enemy and not is_sandyak(enemy):
        return True
    return False

```

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [January 9, 2015, 1:25am UTC](https://discourse.codecombat.com/t/cannot-read-property-formals-of-null/2243/2 "2015-01-09T01:25:43Z")

</div>

That is weird. The simple fix would be to check null status outside the function:

if enemy and is\_soldier(enemy):

But, no idea why you would need to do that instead of just passing enemy into the function.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [January 9, 2015, 2:12am UTC](https://discourse.codecombat.com/t/cannot-read-property-formals-of-null/2243/3 "2015-01-09T02:12:40Z")

</div>

Interesting, probably hitting some new corner case in the Python transpilation process. I’ve opened a bug here (which may get moved): [https://github.com/codecombat/codecombat/issues/2073](https://github.com/codecombat/codecombat/issues/2073)
