From 0be9d7204d7e918060c169a4f175ef7be3f3adc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 8 Dec 2023 13:03:25 -0800 Subject: [PATCH] make EntitlementSetAccess incomparable --- runtime/common/incomparable.go | 25 +++++++++++++++++++++++++ runtime/sema/access.go | 1 + 2 files changed, 26 insertions(+) create mode 100644 runtime/common/incomparable.go diff --git a/runtime/common/incomparable.go b/runtime/common/incomparable.go new file mode 100644 index 0000000000..f83d555555 --- /dev/null +++ b/runtime/common/incomparable.go @@ -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() diff --git a/runtime/sema/access.go b/runtime/sema/access.go index 3c05b4673a..e1d716f4eb 100644 --- a/runtime/sema/access.go +++ b/runtime/sema/access.go @@ -53,6 +53,7 @@ const ( // EntitlementSetAccess type EntitlementSetAccess struct { + _ common.Incomparable Entitlements *EntitlementOrderedSet SetKind EntitlementSetKind }