cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Built-in members are not allowed on AnyResource/AnyStruct

Open SupunS opened this issue 2 years ago • 5 comments

Current Behavior

Consider the below program:

pub fun main(r: @AnyResource) {
  r.uuid
  destroy r
}

This reports an error saying

value of type `AnyResource` has no member `uuid`

Expected Behavior

Built-in members, e.g. fields such as uuid, should be allowed on the type AnyResource/AnyStruct.

Steps To Reproduce

See above

Environment

- Cadence version: Current master, and previously released versions

SupunS avatar May 31 '23 00:05 SupunS

related: AnyResource should also have uuid

bluesign avatar May 31 '23 14:05 bluesign

Maybe we can address this as part of the interface set FLIP: https://github.com/onflow/flips/pull/85#issuecomment-1570876248

turbolent avatar Jun 01 '23 21:06 turbolent

Can be added after 1.0 release

j1010001 avatar Jan 05 '24 19:01 j1010001

updated from removed restricted types, which got removed in Cadence 1.0 and where the replacement, empty intersection types, are not allowed, to just the AnyResource/AnyStruct types.

turbolent avatar Jan 11 '24 05:01 turbolent

I think better solution here is a native UniquelyIdentifieable interface or something similar (for uuid case)

bluesign avatar Jan 11 '24 22:01 bluesign