Skip to content

Commit 42257d6

Browse files
committed
[stdlib] Add Assertion#is_a(Object) clause for checking generic Object assertions.
This first clause matching `Object` is a hack around the fact that `Object` does not _actually_ inherit from `Type`. Because everything in Myst is an Object, an `is_a(Object)` assertion will _always_ pass, so this implementation is accurate, but should probably be addressed in the interpreter to be consistent with the fact that Object _is_ a Type.
1 parent 70b83d6 commit 42257d6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

stdlib/assert.mt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ defmodule Assert
210210

211211
#doc is_a(other : Type) -> self
212212
#| Assert that the value is an instance of `type`.
213+
# TODO: this first clause matching `Object` is a hack around the fact that
214+
# `Object` does not inherit from `Type`. Because everything in Myst is an
215+
# Object, an `is_a(Object)` assertion will _always_ pass, so this
216+
# implementation is accurate, but should probably be addressed in the
217+
# interpreter to be consistent with the fact that Object _is_ a Type.
218+
def is_a(Object) : Assertion; self; end
213219
def is_a(other : Type) : Assertion
214220
unless [@value.type, *@value.type.ancestors].any?{ |anc| anc == other }
215221
raise %AssertionFailure{

0 commit comments

Comments
 (0)