I see mypy more as a refactoring tool, but I'm always pleasantly surprised when it catches issues. It caught a bug here!
demo.py:96: error: Unsupported operand types for >= ("int" and "Optional[int]")
(In the code I've checked max_val is not None, but used min_val.)
Related Posts
I've been using "Expected Int, but got String" for my type error messages, but I've been wondering if I could do better.
"Expected Int here, but this value has type String" or "This expression requires Int, but the value is String".
Do you have a favourite?
I'm changing method definition syntax in my language:
// old
fun (this: Int) inc(): Int { this + 1 }
// new
method inc(this: Int): Int { this + 1 }
The original syntax was inspired by Go, but the new syntax is more grep-friendly and perhaps more readable. Not sure about the verbosity though. Thoughts?
I've added syntax highlighting to the prompt of my programming language!
It's not strictly necessary, but it's nice to have. It caught a bug with lexing incomplete string literals too.