-
Notifications
You must be signed in to change notification settings - Fork 443
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
Return LangError
s from constructors
#1504
Changes from 13 commits
536b500
1ab55d9
79dff48
228604c
bb4c1a2
15439a4
27b6b97
eb10da6
8b1aa66
36556e7
e61576e
a3e0b24
fb8d293
394ffca
2f026a2
c501d84
c307516
aaebac4
b63ef91
0c37262
ec6253d
d56b728
053f570
7305887
0ef75f9
4607a67
f791bfb
5d0f164
e8b4e75
cab6c98
4dc9973
ad1cab7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ evaluable | |
fuzzer | ||
getter | ||
growable | ||
ident | ||
interoperate | ||
invariants | ||
kB | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,7 +334,7 @@ impl Metadata<'_> { | |
} | ||
} | ||
|
||
/// Generates ink! metadata for the storage with given selector and indentation. | ||
/// Generates ink! metadata for the storage with given selector and ident. | ||
fn generate_constructor_return_type( | ||
storage_ident: &Ident, | ||
selector_id: u32, | ||
|
@@ -343,20 +343,28 @@ impl Metadata<'_> { | |
let constructor_info = quote_spanned!(span => | ||
< #storage_ident as ::ink::reflect::DispatchableConstructorInfo<#selector_id>> | ||
); | ||
|
||
quote_spanned!(span=> | ||
::ink::metadata::ReturnTypeSpec::new( | ||
if #constructor_info ::IS_RESULT { | ||
if #constructor_info::IS_RESULT { | ||
::core::option::Option::Some(::ink::metadata::TypeSpec::with_name_str::< | ||
::core::result::Result< | ||
::ink::ConstructorResult<::core::result::Result< | ||
(), | ||
#constructor_info ::Error | ||
> | ||
#constructor_info::Error | ||
>> | ||
>( | ||
"core::result::Result" | ||
"ink_primitives::ConstructorResult" | ||
) | ||
) | ||
} else { | ||
::core::option::Option::None | ||
::core::option::Option::Some(::ink::metadata::TypeSpec::with_name_str::< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know enough about all the metadata types to be able to remove this and still get things compiling, so in the interest of time I'm gonna leave it a a follow-up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #1515 |
||
::ink::ConstructorResult< | ||
(), | ||
> | ||
>( | ||
"ink_primitives::ConstructorResult" | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I bet we could fit that all on one line to avoid the ugly indentation e.g. |
||
) | ||
} | ||
) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this control flow again: from a readability perspective, I wonder whether it would be better to have this inside the
Ok
arm of the match. It seems unusual because of the semantics ofreturn_value
returning immediately!
. A casual reader might expect this statement to always be executed. Just a note for something to consider when we get to refactoring this dispatch logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that seems fair enough. I'll leave it for a follow-up since we'll want to change it for messages too