Skip to content

Commit

Permalink
fix u256 as ref type for configurables (#5194)
Browse files Browse the repository at this point in the history
## Description

This PR is part of #4794. It fix an
issue necessary to use `u256` on configurables.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
xunilrj authored Oct 16, 2023
1 parent 7f1422f commit cddd9f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sway-core/src/asm_generation/fuel/fuel_asm_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,12 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> {

// XXX reassess all the places we use this
pub(crate) fn is_copy_type(&self, ty: &Type) -> bool {
ty.is_unit(self.context) || ty.is_bool(self.context) || ty.is_uint(self.context)
ty.is_unit(self.context)
|| ty.is_bool(self.context)
|| ty
.get_uint_width(self.context)
.map(|x| x < 256)
.unwrap_or(false)
}

fn initialise_constant(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"configurables": [],
"configurables": [
{
"configurableType": {
"name": "",
"type": 0,
"typeArguments": null
},
"name": "SOME_U256",
"offset": 108
}
],
"functions": [
{
"attributes": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
script;

configurable {
SOME_U256: u256 = 0x00000000000000000000000000000000000000000000000000000001u256,
}

fn main() -> u256 {
log(0x00000000000000000000000000000000000000000000000000000002u256);
0x00000000000000000000000000000000000000000000000000000001u256
SOME_U256
}

0 comments on commit cddd9f6

Please sign in to comment.