Error when taking out unused variable

So this is an interesting problem.

In my Lunch Card app, AddView, which I'm already having a problem with, has an unused variable:
Code Block
@Environment(\.colorScheme) var colorScheme

The app works fine with it, even if the color scheme doesn't match. I thought a good solution for the color scheme problem would be to get rid of this variable in AddView itself.

Apparently, that's not the right thing to do, and when getting rid of it, I get this message:

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

Like I said, the app works fine with it. It's not used in AddView at all yet still gives me an error basically saying - and correct me if I'm wrong - that there's not enough memory to build body, even though the unused variable reverses that.

You can find the latest code for AddView here.

Accepted Reply

In the latest code for AddView , colorScheme is used.
As far as I tried (keep using colorScheme and removing the line @Environment(\.colorScheme) var colorScheme), I can reproduce the same error.

Check if the variable is really unused, before removing the declaration.

Replies

In the latest code for AddView , colorScheme is used.
As far as I tried (keep using colorScheme and removing the line @Environment(\.colorScheme) var colorScheme), I can reproduce the same error.

Check if the variable is really unused, before removing the declaration.

In the latest code for AddView , colorScheme is used.

You're right, my mistake.