Skip to content

Commit 5cba46c

Browse files
authored
Merge pull request #2181 from actonlang/fix-2132-2135
fixed #2132 and #2135
2 parents 58a1ed9 + 443a57c commit 5cba46c

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Diff for: compiler/actonc/test/typeerrors/ex16.golden

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Building file test/typeerrors/ex16.act using temporary scratch directory
22
Compiling ex16.act for development
33
[error]: Constraint violation
4-
+--> ex16.act@6:9-6:19
4+
+--> ex16.act@6:9-6:22
55
|
66
6 | foo.append(4)
7-
: ^---------
7+
: ^------------
88
: `- ?__builtin__.list[__builtin__.int] does not have an attribute append
99
: Hint: you may need to test if foo is not None
1010
-----+

Diff for: compiler/lib/src/Acton/Solver.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,12 @@ solveImpl env wit w t p = do (cs,t',we) <- instWitness env p
509509
unify (DfltInfo NoLoc 7 Nothing []) t t'
510510
return ([Eqn w (impl2type t p) we], cs)
511511

512-
solveSelAttr env (wf,sc,d) c@(Sel info w t1 n t2)
512+
solveSelAttr env (wf,sc,d) (Sel info w t1 n t2)
513513
= do (cs,tvs,t) <- instantiate env sc
514514
when (tvSelf `elem` snd (polvars t)) (tyerr n "Contravariant Self attribute not selectable by instance")
515515
w' <- newWitness
516516
let e = eLambda [(px0,t1)] (eCallVar w' [app t (tApp (eDot (wf $ eVar px0) n) tvs) $ witsOf cs])
517-
c = Sub (DfltInfo NoLoc 8 Nothing []) w' (subst [(tvSelf,t1)] t) t2
517+
c = Sub (DfltInfo (loc info) 8 Nothing []) w' (subst [(tvSelf,t1)] t) t2
518518
return ([Eqn w (wFun t1 t2) e], c:cs)
519519

520520
-- e1.__setslice__(sl, e2)

Diff for: compiler/lib/src/Acton/Types.hs

+6-5
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ infInitEnv env self (Expr l e : b)
745745
infInitEnv env self b = infSuiteEnv env b
746746

747747
abstractDefs env q eq b = map absDef b
748-
where absDef (Decl l ds) = Decl l (map absDef' ds)
748+
where absDef (Decl l ds) = Decl l (map absDef' ds)
749749
absDef (If l bs els) = If l [ Branch e (map absDef ss) | Branch e ss <- bs ] (map absDef els)
750750
absDef stmt = stmt
751751
absDef' d@Def{} = d{ pos = pos1, dbody = bindWits eq ++ dbody d }
@@ -762,8 +762,9 @@ instance Check Decl where
762762
st <- newTVar
763763
wellformed env1 q
764764
wellformed env1 a
765-
when (inClass env) $ do
766-
unify (DfltInfo l 600 Nothing []) tSelf $ selfType p k dec
765+
when (inClass env) $
766+
-- unify (DfltInfo l 600 Nothing []) tSelf $ selfType p k dec
767+
unify (Simple l "Type of first parameter of class method does not unify with Self") tSelf $ selfType p k dec
767768
(csp,te0,p') <- infEnv env1 p
768769
(csk,te1,k') <- infEnv (define te0 env1) k
769770
(csb,_,b') <- infDefBody (define te1 (define te0 env1)) n p' k' b
@@ -1296,7 +1297,7 @@ instance Infer Expr where
12961297
let con = case t of
12971298
TOpt _ _ -> Sel (Simple l (Pretty.print t ++ " does not have an attribute "++ Pretty.print n ++
12981299
"\nHint: you may need to test if " ++ Pretty.print e ++ " is not None")) w t n t0
1299-
_ -> Sel (DfltInfo (loc e) 86 (Just e) []) w t n t0
1300+
_ -> Sel (DfltInfo l 86 (Just e) []) w t n t0
13001301
return (con : cs, t0, eCall (eVar w) [e'])
13011302

13021303
infer env e@(Rest _ _ _) = notYetExpr e
@@ -1405,7 +1406,7 @@ instance Infer Expr where
14051406
infer env (Paren l e) = do (cs,t,e') <- infer env e
14061407
return (cs, t, Paren l e')
14071408

1408-
inferCall env unwrap l e ps ks = do (cs1,t,e') <- infer env e
1409+
inferCall env unwrap l e ps ks = do (cs1,t,e') <- infer env e{eloc = l}
14091410
(cs1,t,e') <- if unwrap && actorSelf env then wrapped l attrUnwrap env cs1 [t] [e'] else pure (cs1,t,e')
14101411
(cs2,prow,ps') <- infer env ps
14111412
(cs3,krow,ks') <- infer env ks

0 commit comments

Comments
 (0)