Python has Union[T, U, ...] rather than T | U | ... which makes me wonder if Union[T, Union[U, ...]] is treated differently... then again, the annotations are just an IDE hint and mean nothing at runtime
So, today, I've added the support for the ternary conditional operator ?: to my PicoBlaze assembler written in JavaScript. Very soon, I ran into a problem: how to explain to the tokenizer that : is sometimes a part of a label (so that label: should be one single token) and sometimes a token by it...
@MichaelHomer I tried T | U the other day and got an error for calling a method that didn't exist
(Keep in mind I'm stuck on 3.9 for now)
% python3
Python 3.9.6 (default, Dec 7 2023, 05:42:47)
[Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x: int | str = 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'type' and 'type'
Though I just tried it on a different machine that has 3.10 and it worked, so TIL