How can I correct this function compile error?

You can make some rule for yourself never to use analog outside of 255, but It physically works for me.

Why don't you write a simple sketch as per PaulS' suggestion, and find the root of your misconception?

Discussed here, but apparently ignored.

In fact, try this: analogWrite (PWMpin, 512);
I think we'd all agree that 512 is outside of 255.

AnalogWrite gives it 1023/1023 units of brightness

sp. "255/255"