# 'static consuming func ...' throws 'Static functions must not be declared mutating' compiler error?

**URL:** <https://forums.swift.org/t/static-consuming-func-throws-static-functions-must-not-be-declared-mutating-compiler-error/79949>\
**Category:** Using Swift\
**Tags:** ownership, bug, static, function, compiler-warning\
**Created:** [May 17, 2025, 2:04pm UTC](https://forums.swift.org/t/static-consuming-func-throws-static-functions-must-not-be-declared-mutating-compiler-error/79949 "2025-05-17T14:04:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodebyCR](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/codebycr/32/34814_2.png) [@CodebyCR](https://forums.swift.org/u/CodebyCR)\
**Post date:** [May 17, 2025, 2:04pm UTC](https://forums.swift.org/t/static-consuming-func-throws-static-functions-must-not-be-declared-mutating-compiler-error/79949/1 "2025-05-17T14:04:16Z")

</div>

Hey there,

I wrote some Swift code as I got the following compiler error:

> 'Static functions must not be declared mutating'

I was confused, because I try to avoid mutations if I can.  
So I simplified the method and get the same result with the following function:

```Swift
    public static consuming func createTuple() -> (Int, Int) {
        let two = 2
        let five = 5
        return (two, five)
    }

```

Is this intended behaviour, a compiler bug and / or a bad error message?  
I use Xcode 16.3 with Swift 5.10.

It seems to be the combination of `static` and `consuming` in the function head.

---

<div class="post-metadata">

**Author:** ![michelf](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michelf/32/1180_2.png) [@michelf](https://forums.swift.org/u/michelf)\
**Post date:** [May 17, 2025, 2:20pm UTC](https://forums.swift.org/t/static-consuming-func-throws-static-functions-must-not-be-declared-mutating-compiler-error/79949/2 "2025-05-17T14:20:03Z")

</div>

I'm pretty sure this is just the error message mixing the words "consuming" and "mutating".

In a `consuming` function, "consuming" applies to the hidden `self` argument. A static function has no `self`, so can't be consuming. The same is true with `static mutating`, and the check in the compiler is apparently spitting the same error message in both cases.

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [May 17, 2025, 2:24pm UTC](https://forums.swift.org/t/static-consuming-func-throws-static-functions-must-not-be-declared-mutating-compiler-error/79949/3 "2025-05-17T14:24:09Z")

</div>

> [@michelf](#):
>
> A static function has no `self`

One nitpick: static functions do have a `self`, which refers to the metatype:

```swift
struct S {
    static func f() {
        print(self)
    }
}
S.f() // "S"

```

But the rest of the point stands: metatypes are static data, so they can't be consumed. The error message could probably be improved here.
