From 9c2e92d7d9759ab19a7af67e8cb5bd21a13f0c31 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 20 Jan 2022 21:13:35 +0300 Subject: [PATCH] compiler: check overloaded methods for safeness one more time It's possible that overloaded method is marked as `safe` in manifest, so that it must have `save` field set to true after its name was overwritten. --- pkg/compiler/debug.go | 7 +++++++ pkg/smartcontract/manifest/standard/comply.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index 9a80ffd3f..b8bf2b306 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -461,6 +461,13 @@ func (di *DebugInfo) ConvertToManifest(o *Options) (*manifest.Manifest, error) { "multiple methods with the same number of parameters", name) } m.Name = emitName + // Check the resulting name against set of safe methods. + for i := range o.SafeMethods { + if m.Name == o.SafeMethods[i] { + m.Safe = true + break + } + } } return result, nil } diff --git a/pkg/smartcontract/manifest/standard/comply.go b/pkg/smartcontract/manifest/standard/comply.go index 35986b225..26a87a391 100644 --- a/pkg/smartcontract/manifest/standard/comply.go +++ b/pkg/smartcontract/manifest/standard/comply.go @@ -129,7 +129,7 @@ func checkMethod(m *manifest.Manifest, expected *manifest.Method, } } if expected.Safe != actual.Safe { - return fmt.Errorf("%w: expected %t", ErrSafeMethodMismatch, expected.Safe) + return fmt.Errorf("'%s' %w: expected %t", expected.Name, ErrSafeMethodMismatch, expected.Safe) } return nil }