Repository navigation
Description
Given:
obj oT() {
fn get() -> int {
ret 3;
}
fn foo() {
auto c = get();
}
}
fn main() {
}
Rustboot crashes with:
Fatal error: exception Failure("internal_check_base_lval: unexpected defn type")
Raised at file "pervasives.ml", line 22, characters 22-33
Called from file "boot/me/type.ml", line 280, characters 15-77
Called from file "boot/me/type.ml", line 461, characters 17-47
Called from file "boot/me/type.ml", line 492, characters 6-64
Called from file "boot/me/type.ml", line 598, characters 20-37
Called from file "boot/me/type.ml", line 715, characters 23-45
Called from file "boot/me/type.ml", line 820, characters 8-23
Re-raised at file "boot/me/type.ml", line 633, characters 6-189
Called from file "boot/me/type.ml", line 926, characters 8-51
Called from file "boot/me/walk.ml", line 134, characters 4-9
Called from file "array.ml", line 117, characters 31-48
Called from file "boot/me/walk.ml", line 135, characters 4-15
Called from file "boot/me/walk.ml", line 320, characters 2-23
Called from file "hashtbl.ml", line 145, characters 8-13
Called from file "hashtbl.ml", line 148, characters 4-19
Called from file "boot/me/walk.ml", line 186, characters 12-59
Called from file "boot/me/walk.ml", line 135, characters 4-15
Called from file "hashtbl.ml", line 145, characters 8-13
Called from file "hashtbl.ml", line 148, characters 4-19
Called from file "boot/me/walk.ml", line 135, characters 4-15
Called from file "boot/me/type.ml", line 955, characters 4-231
Re-raised at file "boot/me/type.ml", line 35, characters 4-112
Called from file "boot/driver/main.ml", line 322, characters 9-26
Called from file "array.ml", line 117, characters 31-48
Called from file "boot/driver/main.ml", line 320, characters 4-366
Called from file "boot/driver/main.ml", line 404, characters 5-21
The crash goes away if foo() calls a global function, and I get an appropriate error message if the function is just misspelled.
Activity
graydon commentedon Jul 17, 2010
Bug in the new typechecker and/or resolver; I'll fix that part. It should trap earlier.
However, this is also a language non-feature (at present). Currently there's no mechanism for self-dispatch inside an object, either implicitly as you're doing, or via this.get(). There's no 'this' binding at all. It's not a ton of work to add, I've been hesitant to see if (a) it's necessary and (b) it will interact with whatever mechanism gets adopted for ad-hoc object extension / method replacement, which we haven't settled on yet.
And I was also curious to see how far we could get without the feature. In general I only wish to adopt OO features "one at a time" as seems necessary, and stick to the minimum. The "class" concept in many OO languages is the semantic dumping ground of every language feature ever, and I don't want to wind up in that boat.
jyasskin commentedon Jul 17, 2010
Ah, didn't realize that. I've documented this restriction in jyasskin/rust@6e967f4. Not having it doesn't seem like the end of the world to me, and that'll certainly simplify the specification of method overriding.
graydon commentedon Jul 19, 2010
Fix over-optimistic resolution of self-methods within obj scopes. There is no such feature in the language at present. Add test to prevent regression. Closed by f1db420.
Fix over-optimistic resolution of self-methods within obj scopes. The…
Merge pull request rust-lang#114 from matthewjasper/keyword-spelling
Merge pull request rust-lang#114 from wasmerio/mem-alignment
Merge pull request rust-lang#114 from bjorn3/sync_from_rust
Harnesses for carrying_mul (rust-lang#114)
[SOL] Bump compiler builtins commit (rust-lang#114)
[SOL] Bump compiler builtins commit (rust-lang#114)
book: Fix links (rust-lang#114)
Update generated.rs.tera
Merge rust-lang#120
book: Fix links (rust-lang#114)
Update README