lang: refactor anticipating io_forget_history

This commit is contained in:
Nigel Tao committed 2024-02-09 14:55:35 +11:00
1 parent c21cc95713
commit e8af2d0635
5 files changed
+60 -44

No files matched your search

+4 -2
View File
@@ -265,8 +265,10 @@ func (q *checker) bcheckStatement(n *a.Node) error {
if _, err := q.bcheckExpr(n.IO(), 0); err != nil {
return err
}
if _, err := q.bcheckExpr(n.Arg1(), 0); err != nil {
return err
if arg1 := n.Arg1(); arg1 != nil {
if _, err := q.bcheckExpr(arg1, 0); err != nil {
return err
}
}
if histPos := n.HistoryPosition(); histPos != nil {
if _, err := q.bcheckExpr(histPos, 0); err != nil {
+13 -8
View File
@@ -160,16 +160,21 @@ func (q *checker) tcheckStatement(n *a.Node) error {
n.Keyword().Str(q.tm), n.IO().Str(q.tm), typ.Str(q.tm))
}
arg1Typ := typeExprSliceU8
if n.Keyword() == t.IDIOLimit {
arg1Typ := (*a.TypeExpr)(nil)
switch n.Keyword() {
case t.IDIOBind:
arg1Typ = typeExprSliceU8
case t.IDIOLimit:
arg1Typ = typeExprU64
}
if err := q.tcheckExpr(n.Arg1(), 0); err != nil {
return err
}
if typ := n.Arg1().MType(); !typ.EqIgnoringRefinementsLHSReadOnly(arg1Typ) {
return fmt.Errorf("check: %s expression %q, of type %q, does not have type %q",
n.Keyword().Str(q.tm), n.Arg1().Str(q.tm), typ.Str(q.tm), arg1Typ.Str(q.tm))
if arg1Typ != nil {
if err := q.tcheckExpr(n.Arg1(), 0); err != nil {
return err
}
if typ := n.Arg1().MType(); !typ.EqIgnoringRefinementsLHSReadOnly(arg1Typ) {
return fmt.Errorf("check: %s expression %q, of type %q, does not have type %q",
n.Keyword().Str(q.tm), n.Arg1().Str(q.tm), typ.Str(q.tm), arg1Typ.Str(q.tm))
}
}
if n.Keyword() == t.IDIOBind {