# Unit can't be called in this context by implicit receiver

**URL:** <https://discuss.kotlinlang.org/t/unit-cant-be-called-in-this-context-by-implicit-receiver/22133>\
**Category:** Support\
**Created:** [June 15, 2021, 5:43pm UTC](https://discuss.kotlinlang.org/t/unit-cant-be-called-in-this-context-by-implicit-receiver/22133 "2021-06-15T17:43:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skumaran](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@skumaran](https://discuss.kotlinlang.org/u/skumaran)\
**Post date:** [June 15, 2021, 5:43pm UTC](https://discuss.kotlinlang.org/t/unit-cant-be-called-in-this-context-by-implicit-receiver/22133/1 "2021-06-15T17:43:03Z")

</div>

This was a kotlin error that I encountered while I was working with Teamcity.  
The error message was

> Unit can’t be called in this context by implicit receiver

What does this mean?

I am following this Kotlin example ([Kotlin DSL | TeamCity On-Premises Documentation](https://www.jetbrains.com/help/teamcity/kotlin-dsl.html#Editing+Kotlin+DSL)) and trying to write a kotlin script for my CI.

This is my code snippet

```auto
steps {
    script {
        name = "Style check"
        id("StyleCheck")
        enabled = false
        scriptContent = """
            #!/bin/bash

            make docker run="make ci lint"
        """.trimIndent()
    }

```

I get an Error for the id() call which says

[![Error message](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/5/57e53cc6081f4d2e32083ae06eb90abbaba96301.png)](https://i.stack.imgur.com/go7g5.png)

- What does the error message mean?
- How can I use `id()` call as given in the example?

---

<div class="post-metadata">

**Author:** ![nickallendev](https://avatars.discourse-cdn.com/v4/letter/n/cdc98d/32.png) [@nickallendev](https://discuss.kotlinlang.org/u/nickallendev)\
**Post date:** [June 15, 2021, 7:55pm UTC](https://discuss.kotlinlang.org/t/unit-cant-be-called-in-this-context-by-implicit-receiver/22133/2 "2021-06-15T19:55:02Z")

</div>

Looks like the scripts block does not provide an `id` method. I think you want `id = "StyleCheck"` based on one of the examples in that page.

The error is probably there because an `id` method is provided by one of the surrounding scopes, but the TeamCity DSL has used the `@DslMarker` attribute to block users from accidentally affecting outer DSL scopes from nested DSL scopes like you seem to be doing. 😉

See [Type-safe builders | Kotlin](https://kotlinlang.org/docs/type-safe-builders.html#scope-control-dslmarker) if curious about `@DslMarker`.

---

<div class="post-metadata">

**Author:** ![skumaran](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@skumaran](https://discuss.kotlinlang.org/u/skumaran)\
**Post date:** [June 15, 2021, 8:16pm UTC](https://discuss.kotlinlang.org/t/unit-cant-be-called-in-this-context-by-implicit-receiver/22133/3 "2021-06-15T20:16:17Z")

</div>

> [@nickallendev](#):
>
> See [Type-safe builders | Kotlin](https://kotlinlang.org/docs/type-safe-builders.html#scope-control-dslmarker) if curious about `@DslMarker` .

Thank you, much. This explains how usage in the scope was blocked.
