So, as of yesterday, rustc can compile self-calls (like self.foo()) as long as they don't have arguments, and the resulting code even runs as you might expect! But self-calls with arguments don't compile. The error we get is "ann_to_type() called on node with no type".
>From what I can tell, the 'ann' part of an AST node is a type annotation, >originally empty. The check_expr function in typeck.rs takes a function >context and an AST node and returns an AST node with the 'ann' part filled in. > (Correct me if I'm mistaken about any of this.) Right now, for >expr_call_self nodes, we're not filling in anything in that spot, hence the >error. The question is, *what* should we fill it in with? My first idea was to look at what we're doing for expr_call nodes in typeck.check_expr, and hack it up to work for expr_call_self nodes. This seems like it could work, analogously to how we hacked up trans.trans_call yesterday to be able to process self-call expressions as well as regular call expressions. But the analogous thing to do in check_expr, when given an self-call expression, would be to just call check_call, passing the *entire self-call expr* to it. Right now we can't do that, because the self-call expr would just go through to check_call_or_bind, then back to check_expr, and loop infinitely. So, maybe check_call_or_bind (or maybe just check_call; not sure where this functionality should go) needs to behave differently, depending on whether it is dealing with an expr_call_self node. Yesterday we essentially added a new field to the type fn_ctxt in trans.rs. What used to be an option[ValueRef] called 'llself' is now an option of a *record* containing a ValueRef and a @ty.t. That @ty.t is what makes it possible to translate self-calls (because we know about the type of the object we're currently in -- or something like that; I don't understand it completely). I think that we need to do something analogous in typeck.rs, which, confusingly, has its *own* fn_ctxt type defined. that is, I think we need to add a new field 'ty_self' (or what have you) to the typeck.fn_ctxt type. But I'm not sure how/where we are supposed to be putting anything in that field. So that's where I am. This discussion is probably best continued on IRC, or in person, as we look at the code, but I wanted to first braindump what I've thought of so far. :) Lindsey _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
