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

Fixes assert_eq always passing for U256 #5054

Merged
merged 6 commits into from Aug 30, 2023
Merged

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Aug 29, 2023

Description

The issue was occurring because get_items_for_type_and_trait_name was comparing an absolute call path to an external relative call path, when the second should also be absolute.

compile_fn now checks if method is trait dummy.

These changes should avoid the silent failures where a dummy method is used,
instead of the proper implementation.

Closes #4989

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

The issue was occuring because `get_items_for_type_and_trait_name` was comparing
an absolute call path to an external relative call path, when the second should
also be absolute.
These changes should avoid the silent failures where a dummy method is used,
instead of the proper implementation.
@esdrubal esdrubal added P: critical Should be looked at before anything else compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Aug 29, 2023
@esdrubal esdrubal self-assigned this Aug 29, 2023
@anton-trunov
Copy link
Contributor

It seems that one more way to fix this for a lot of cases without introducing the is_trait_method_dummy flag would be to check if the function body is empty and the return type is not (). Although, there is one more case to handle, legitimate functions like this one:

fn foo(...) {
}

On the other hand those functions are kind of useless and we might as well prohibit functions with the empty body and require the user to write something like this

fn foo(...) {
    return ()
}

Just some food for thought :)

…ait_name.

`get_items_for_type_and_trait_name` was called with local prexies when it
should only have `core::ops::` prefixes. This was caused by import_star
receiving a src with the mod_path prepended.
@esdrubal esdrubal requested a review from a team August 29, 2023 11:44
@esdrubal esdrubal enabled auto-merge (squash) August 30, 2023 08:55
@esdrubal esdrubal merged commit 9b986af into master Aug 30, 2023
28 checks passed
@esdrubal esdrubal deleted the esdrubal/4989_u256_assert_eq branch August 30, 2023 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen P: critical Should be looked at before anything else
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert_eq always pass for U256
4 participants