Turf lets you share a constant value across multiple files with pub immut, but not a value that other files could change – a true mutable global. So writing export mut (or pub mut at the top level) trips this error, even though a plain mut variable inside a function is completely normal everywhere else in Turf.
export mut counter: int = 0;This looks reasonable, but counter being both mut (changeable) and shared across files at the same time isn’t supported. If you just need a constant that many files can read, make it a public constant:
pub immut MAX_USERS: int = 100;Now every file that imports this one can read MAX_USERS, and since it’s immut, there’s no ambiguity about who’s allowed to change it (nobody – that’s the point). export immut means the same as pub immut, and warns (E176) with a fix that writes pub.
If you genuinely need a value that changes and is visible everywhere, keep the mutable value inside one file – in a struct that a function owns – and let other files interact with it through functions you write yourself, something like a get_counter()/set_counter() pair, rather than reaching in and changing it directly. It’s a bit more typing, but it also means you always know exactly which piece of code is allowed to change the value, which tends to save you from confusing bugs down the road anyway.
Run turf --explain E021 in a terminal to read this again.