Mostly c/c++/c# but also know some python and rust.
This is just for self educarion/exploration. Nothing critical.
Even you said your rule of thumb is "not strictly true" which is my point. Is there some way to check those cases? Like I can verify the type of a variable returned by a function. Like if I get people's ages from a database but some one stored them in a text field instead of an numeric field. When I get the data back I can verify the type before I try to say average the ages.
A simple idea of what I'm thinking is let's say you're doing very precise calculations which need to very accurate so a co-worker makes a custom double class and returns that from their special add function. Since it's an instance of a custom class it's likely stored on the heap. Naming is hard though so your coworker named it Double instead of double. So you look at your code and think Double is a primitive so should be on the stack but it's actually on the heap. Even simpler example, primitive types are stack based except for string which is heap based. These are easy mistakes to make but could have performance and memory implications. So a way of verifying assumptions would be useful.