Skip to content

Commit

Permalink
Merge pull request #2972 from onflow/bastian/incomparable
Browse files Browse the repository at this point in the history
Make entitlement set access incomparable
  • Loading branch information
turbolent authored Dec 13, 2023
2 parents 3946910 + 0be9d72 commit 6dc945f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions runtime/common/incomparable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Cadence - The resource-oriented smart contract programming language
*
* Copyright Dapper Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package common

// Incomparable (the zero-sized type [0]func()) makes the surrounding incomparable.
// It is crucial to ensure its placed at the beginning or middle of the surrounding struct,
// and NOT at the end of the struct, as otherwise the compiler will add padding bytes.
// See https://i.hsfzxjy.site/zst-at-the-rear-of-go-struct/ for more details
type Incomparable [0]func()
1 change: 1 addition & 0 deletions runtime/sema/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
// EntitlementSetAccess

type EntitlementSetAccess struct {
_ common.Incomparable
Entitlements *EntitlementOrderedSet
SetKind EntitlementSetKind
}
Expand Down

0 comments on commit 6dc945f

Please sign in to comment.