You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following code, foo has an Optional[A] argument and does a check on it to see if is None or defined:
classA:
passdeffoo(maybe_a: Optional[A]):
ifmaybe_a:
print("maybe_a is defined")
foo(A())
This works, and correctly prints "maybe_a is defined".
However, if class a class B is defined and inherits from A, the exact same code will break at compile time:
classA:
passclassB(A):
passdeffoo(maybe_a: Optional[A]):
ifmaybe_a:
print("maybe_a is defined")
foo(A())
internal.codon:364:16-49: error: '__internal__' object has no method 'class_raw_rtti_ptr' with arguments ()
├─ optional.codon:25:20-53: error: during the realization of opt_ref_bool_rtti(what: Optional[class_ctr[...,...]], T: class_ctr[...,...])
├─ optional.codon:43:16-30: error: during the realization of __has__(self: Optional[A])
├─ test.py:8:5-54: error: during the realization of __bool__(self: Optional[A])
╰─ test.py:11:1-4: error: during the realization of foo(maybe_a: Optional[A])
This breaks also with other types of checks: maybe_a is not None and maybe_a != None
The text was updated successfully, but these errors were encountered:
Tenchi2xh
changed the title
Inheritence breaks Optional
Inheritance breaks Optional
Apr 28, 2024
Tenchi2xh
added a commit
to Tenchi2xh/RTOW-Codon
that referenced
this issue
Apr 28, 2024
In the following code,
foo
has anOptional[A]
argument and does a check on it to see if isNone
or defined:This works, and correctly prints
"maybe_a is defined"
.However, if class a class
B
is defined and inherits fromA
, the exact same code will break at compile time:This breaks also with other types of checks:
maybe_a is not None
andmaybe_a != None
The text was updated successfully, but these errors were encountered: