Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930package types
// IsCastable returns true if the `a` type can be casted to the `b` type using an explicit cast.func IsCastable(a Type, b Type) bool { if a == b || a == Any { return true }
_, aIsPointer := a.(*Pointer) _, bIsPointer := b.(*Pointer)
if aIsPointer && bIsPointer { return true }
aIsInt := Is(a, AnyInt) bIsInt := Is(b, AnyInt)
if (aIsInt || aIsPointer) && bIsInt { return true }
_, aIsFunction := a.(*Function)
if aIsFunction && (bIsInt || bIsPointer) { return true }
return false}