the inconsistency comes from the fact that this reactivity, triggered from inside a function, is not taken into account to build the dependency graph and ultimately decide in which order to process the statements
let name = 'world';
const flip = () => name = name === name.toUpperCase() ? name.toLowerCase() : name.toUpperCase()
$: console.log({ name })
</script>