Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Crash in rustboot on bad type conversion in ret #113

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

Crash in rustboot on bad type conversion in ret #113

jyasskin opened this issue Jul 17, 2010 · 3 comments

Comments

@jyasskin
Copy link
Contributor

Given:

fn mk_int() -> uint {
  let int i = 3;
  ret i;
}
fn main() {
}

Rustboot crashes with:

Fatal error: exception Assert_failure("boot/me/trans.ml", 2988, 6)
Raised at file "boot/me/trans.ml", line 2989, characters 6-652
Called from file "boot/me/trans.ml", line 4442, characters 27-46
Called from file "boot/me/trans.ml", line 4055, characters 6-26
Re-raised at file "boot/me/trans.ml", line 4072, characters 11-104
Called from file "array.ml", line 117, characters 31-48
Called from file "boot/me/trans.ml", line 1974, characters 4-36
Called from file "boot/me/trans.ml", line 4604, characters 4-20
Called from file "boot/me/trans.ml", line 4999, characters 4-39
Called from file "boot/me/semant.ml", line 1435, characters 4-17
Called from file "boot/me/semant.ml", line 1561, characters 4-50
Called from file "boot/me/walk.ml", line 134, characters 4-9
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 "array.ml", line 130, characters 31-51
Called from file "boot/driver/session.ml", line 60, characters 10-17
Called from file "boot/me/semant.ml", line 1861, characters 8-84
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

Changing the 'int' to 'uint' causes the correct "mismatched types" error (although the "expected" type isn't what I would have expected), and changing the 'uint' to 'int' makes the code compile fine, even if (say) an interface conversion is involved.

@graydon
Copy link
Contributor

graydon commented Jul 17, 2010

Bug in the new typechecker, it should catch that. Trans trapping late like that is no fun.

The residual behavior is what I'd expect though: changing int to uint makes it complain at the initialization point, yes? Because 3 is an int, not a uint. And changing uint to int makes it compile, because then everyone's dealing with ints everywhere and there's no error.

What did you mean by interface conversion?

@jyasskin
Copy link
Contributor Author

I agree the residual behavior is right. I though it would "expect" uint (the function's return type) and find int, but instead it's the other way around. That's just a UI issue, though, nothing to do with correctness.

By interface conversion, I meant something like
type intfc = obj { fn foo(); };
obj impl() { fn foo() {} }
fn bar() -> intfc { ret impl(); }
where it needs to convert a concrete type to an interface type.

@graydon
Copy link
Contributor

graydon commented Jul 19, 2010

Missing semicolon in type.ml, plus test to catch regression. Closed by bacb8e6.

oli-obk added a commit to oli-obk/rust that referenced this issue Jul 19, 2017
oli-obk added a commit to oli-obk/rust that referenced this issue Jul 19, 2017
kazcw pushed a commit to kazcw/rust that referenced this issue Oct 23, 2018
This commit adds a new builder on CI for running tests in Intel's own emulator
and also adds an assertion that on this emulator no tests are skipped due to
missing CPU features by accident.

Closes rust-lang#92
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
Introduction: Add link to the Rust Reference repository
djtech-dev pushed a commit to djtech-dev/rust that referenced this issue Dec 9, 2021
bjorn3 added a commit to bjorn3/rust that referenced this issue Dec 31, 2021
rustc_interface already calls it for you
celinval pushed a commit to celinval/rust-dev that referenced this issue Nov 29, 2024
…-lang#113)

Towards rust-lang#76 

### Changes
* Adds contracts for `<*mut T>::add`, `<*mut T>::sub` and `<*mut
T>::offset`
* Adds proofs for contracts of the above functions verifying the pointee
types:
  * All integer types
  * Tuples (composite type)
  * Unit Type
* Defines a macro for add and sub and another for offset.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: Yifei Wang <[email protected]>
Co-authored-by: MayureshJoshi25 <[email protected]>
Co-authored-by: Yifei Wang <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants