lang: allow "slice_var as ptr array[etc] etc"

This commit is contained in:
Nigel Tao committed 2023-06-13 22:38:25 +10:00
1 parent 6411561deb
commit 19f56ebfd2
7 files changed
+83 -5

No files matched your search

+10
View File
@@ -941,6 +941,16 @@ func (n *TypeExpr) IsReadOnly() bool {
return (n.id0 == t.IDRoarray) || (n.id0 == t.IDRoslice) || (n.id0 == t.IDRotable)
}
func (n *TypeExpr) IsRecursivelyReadOnly() bool {
for ; n != nil; n = n.Inner() {
switch n.id0 {
case t.IDRoarray, t.IDRoslice, t.IDRotable:
return true
}
}
return false
}
func (n *TypeExpr) IsContainerOfSpecificNumType(container t.ID, numType t.ID) bool {
return (n.id0 == container) && n.Inner().IsNumType() && (n.Inner().id2 == numType)
}