| 4286 | | error("pure function '%s' cannot access mutable static data '%s'", |
|---|
| 4287 | | sc->func->toChars(), v->toChars()); |
|---|
| 4288 | | } |
|---|
| 4289 | | else if (sc->func->isPure() && |
|---|
| 4290 | | sc->parent->pastMixin() != v->parent->pastMixin() && |
|---|
| 4291 | | !v->isImmutable() && |
|---|
| 4292 | | !(v->storage_class & STCmanifest)) |
|---|
| 4293 | | { |
|---|
| 4294 | | error("pure nested function '%s' cannot access mutable data '%s'", |
|---|
| 4295 | | sc->func->toChars(), v->toChars()); |
|---|
| 4296 | | if (v->isEnumDeclaration()) |
|---|
| 4297 | | error("enum"); |
|---|
| | 4282 | /* If ANY of its enclosing functions are pure, |
|---|
| | 4283 | * it cannot do anything impure. |
|---|
| | 4284 | * If it is pure, it cannot access any mutable variables other |
|---|
| | 4285 | * than those inside itself |
|---|
| | 4286 | */ |
|---|
| | 4287 | if (hasPureParent && v->isDataseg() && |
|---|
| | 4288 | !v->isImmutable()) |
|---|
| | 4289 | { |
|---|
| | 4290 | error("pure function '%s' cannot access mutable static data '%s'", |
|---|
| | 4291 | sc->func->toChars(), v->toChars()); |
|---|
| | 4292 | } |
|---|
| | 4293 | else if (sc->func->isPure() && |
|---|
| | 4294 | sc->parent->pastMixin() != v->parent->pastMixin() && |
|---|
| | 4295 | !v->isImmutable() && |
|---|
| | 4296 | !(v->storage_class & STCmanifest)) |
|---|
| | 4297 | { |
|---|
| | 4298 | error("pure nested function '%s' cannot access mutable data '%s'", |
|---|
| | 4299 | sc->func->toChars(), v->toChars()); |
|---|
| | 4300 | if (v->isEnumDeclaration()) |
|---|
| | 4301 | error("enum"); |
|---|
| | 4302 | } |
|---|