Skip to content

One method calling another crashes rustboot #114

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jyasskin opened this issue Jul 17, 2010 · 3 comments
Closed

One method calling another crashes rustboot #114

jyasskin opened this issue Jul 17, 2010 · 3 comments

Comments

@jyasskin
Copy link
Contributor

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.

@graydon
Copy link
Contributor

graydon commented 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
Copy link
Contributor Author

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
Copy link
Contributor

graydon commented 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.

mbrubeck pushed a commit to mbrubeck/rust that referenced this issue Oct 17, 2011
…re is no such feature in the language at present. Add test to prevent regression. Closes rust-lang#114.
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
djtech-dev pushed a commit to djtech-dev/rust that referenced this issue Dec 9, 2021
Add set_alignment and get_alignment on InstructionValue.
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Jan 23, 2022
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Oct 29, 2024
## Towards: Issue rust-lang#59

### Parent branch: main

---

### Changes


- Added macros for generating `carrying_mul` harnesses
- Added harnesses for `carrying_mul` for the following integer types:
  - `u8`, `u16`, `u32`, `u64`

---------

Co-authored-by: yew005 <yew005@ucsd.edu>
Co-authored-by: MWDZ <jinjunfeng721@gmail.com>
Co-authored-by: Yenyun035 <yenyunw@andrew.cmu.edu>
Co-authored-by: Rajath <rajathkotyal@gmail.com>
Co-authored-by: Rajath Kotyal <53811196+rajathkotyal@users.noreply.github.com>
This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants