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

Update atree register inlining v1.0 #3359

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npm-packages/cadence-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onflow/cadence-parser",
"version": "1.0.0-preview.28",
"version": "1.0.0-preview.29",
"description": "The Cadence parser",
"homepage": "https://github.com/onflow/cadence",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions runtime/sema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5150,8 +5150,8 @@ func (*CompositeType) IsComparable() bool {
return false
}

func (*CompositeType) ContainFieldsOrElements() bool {
return true
func (t *CompositeType) ContainFieldsOrElements() bool {
return t.Kind != common.CompositeKindEnum
}

func (t *CompositeType) TypeAnnotationState() TypeAnnotationState {
Expand Down
23 changes: 23 additions & 0 deletions runtime/tests/checker/entitlements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,29 @@ func TestCheckBasicEntitlementMappingAccess(t *testing.T) {

assert.NoError(t, err)
})

t.Run("enum field", func(t *testing.T) {
t.Parallel()

_, err := ParseAndCheck(t, `
enum Status: Int {
case On
case Off
}

entitlement mapping M {}

struct interface S {
// enum cases are public.
// Hence, using entitlement mappings for enum-typed variables are pointless.
// So reject this statically.
access(mapping M) let status: Status
}
`)

errs := RequireCheckerErrors(t, err, 1)
require.IsType(t, &sema.InvalidMappedEntitlementMemberError{}, errs[0])
})
}

func TestCheckInvalidEntitlementAccess(t *testing.T) {
Expand Down
22 changes: 22 additions & 0 deletions runtime/tests/checker/for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,26 @@ func TestCheckReferencesInForLoop(t *testing.T) {

require.NoError(t, err)
})

t.Run("Enum array", func(t *testing.T) {
t.Parallel()

_, err := ParseAndCheck(t, `
enum Status: Int {
case On
case Off
}

fun main() {
var array = [Status.On, Status.Off]
var arrayRef = &array as &[Status]

for element in arrayRef {
let e: Status = element
}
}
`)

require.NoError(t, err)
})
}
26 changes: 26 additions & 0 deletions runtime/tests/checker/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,4 +961,30 @@ func TestCheckMemberAccess(t *testing.T) {
})
}
})

t.Run("composite reference, enum field", func(t *testing.T) {
t.Parallel()

_, err := ParseAndCheck(t, `
struct Test {
var status: Status
init() {
self.status = Status.Off
}
}

enum Status: Int {
case On
case Off
}

fun test() {
let test = Test()
let testRef = &test as &Test
var x: Status = testRef.status
}
`)

require.NoError(t, err)
})
}
2 changes: 1 addition & 1 deletion tools/storage-explorer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/gorilla/mux v1.8.1
github.com/onflow/atree v0.8.0-rc.1
github.com/onflow/atree v0.8.0-rc.2
github.com/onflow/cadence v1.0.0-M8
github.com/onflow/flow-go v0.34.0-crescendo-preview.5.0.20240229164931-a67398875618
github.com/rs/zerolog v1.32.0
Expand Down
1 change: 1 addition & 0 deletions tools/storage-explorer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,7 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs
github.com/onflow/atree v0.6.1-0.20240429171214-e4400b25dfa9 h1:lS/47Nt8qRIEC+V8QPobTAWnudK982u/wJboucugndg=
github.com/onflow/atree v0.6.1-0.20240429171214-e4400b25dfa9/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A=
github.com/onflow/atree v0.8.0-rc.1/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A=
github.com/onflow/atree v0.8.0-rc.2/go.mod h1:7YNAyCd5JENq+NzH+fR1ABUZVzbSq9dkt0+5fZH3L2A=
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240227190927-0e6ce7e3222b h1:oXHQft30sElpK7G3xWB5tEizI2G+S4p64iVh0LtX4E0=
Expand Down
2 changes: 1 addition & 1 deletion version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading