Skip to content
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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ build-commands: ./cmd/parse/parse ./cmd/parse/parse.wasm ./cmd/check/check ./cmd
build-tools: build-analysis build-get-contracts build-compatibility-check

.PHONY: test-tools
test-tools: test-analysis test-compatibility-check
test-tools: test-analysis test-compatibility-check test-subtype-gen

## Analysis tool

Expand Down Expand Up @@ -80,6 +80,12 @@ build-compatibility-check:
test-compatibility-check:
(cd ./tools/compatibility-check && go test .)

## Subtyping generator tool

.PHONY: test-subtype-gen
test-subtype-gen:
(cd ./tools/subtype-gen && go test .)

# Testing

TEST_PKGS := $(shell go list ./... | grep -Ev '/cmd|/analysis|/tools')
Expand Down
1 change: 1 addition & 0 deletions encoding/ccf/ccf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8783,6 +8783,7 @@ func TestEncodeSimpleTypes(t *testing.T) {
ccf.SimpleTypeIssueAccountCapabilityController: cadence.IssueAccountCapabilityControllerType,
ccf.SimpleTypeCapabilitiesMapping: cadence.CapabilitiesMappingType,
ccf.SimpleTypeAccountMapping: cadence.AccountMappingType,
ccf.SimpleTypeStorable: cadence.StorableType,
}

var missingTests []string
Expand Down
3 changes: 3 additions & 0 deletions encoding/ccf/simpletype.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const ( // Cadence simple type IDs
SimpleTypeUFix128
_

SimpleTypeStorable

// !!! *WARNING* !!!
// ADD NEW TYPES *BEFORE* THIS WARNING.
// DO *NOT* ADD NEW TYPES AFTER THIS LINE!
Expand All @@ -174,6 +176,7 @@ func initSimpleTypeIDBiMap() (m *bimap.BiMap[cadence.PrimitiveType, SimpleType])
m.Insert(cadence.StringType, SimpleTypeString)
m.Insert(cadence.CharacterType, SimpleTypeCharacter)
m.Insert(cadence.HashableStructType, SimpleTypeHashableStruct)
m.Insert(cadence.StorableType, SimpleTypeStorable)

m.Insert(cadence.NumberType, SimpleTypeNumber)
m.Insert(cadence.SignedNumberType, SimpleTypeSignedNumber)
Expand Down
11 changes: 7 additions & 4 deletions encoding/ccf/simpletype_string.go

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

1 change: 1 addition & 0 deletions interpreter/memory_metering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9730,6 +9730,7 @@ func TestInterpretStaticTypeStringConversion(t *testing.T) {

switch primitiveStaticType {
case interpreter.PrimitiveStaticTypeAny,
interpreter.PrimitiveStaticTypeStorable,
interpreter.PrimitiveStaticTypeUnknown,
interpreter.PrimitiveStaticType_Count:
continue
Expand Down
10 changes: 8 additions & 2 deletions interpreter/primitivestatictype.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const (
PrimitiveStaticTypeAnyResourceAttachment
PrimitiveStaticTypeAnyStructAttachment
PrimitiveStaticTypeHashableStruct
_
PrimitiveStaticTypeStorable
_
_

Expand Down Expand Up @@ -273,7 +273,8 @@ func (t PrimitiveStaticType) elementSize() uint {
PrimitiveStaticTypeAny,
PrimitiveStaticTypeAnyStructAttachment,
PrimitiveStaticTypeAnyResourceAttachment,
PrimitiveStaticTypeHashableStruct:
PrimitiveStaticTypeHashableStruct,
PrimitiveStaticTypeStorable:
return UnknownElementSize

case PrimitiveStaticTypeVoid:
Expand Down Expand Up @@ -511,6 +512,9 @@ func (t PrimitiveStaticType) SemaType() sema.Type {
case PrimitiveStaticTypeBlock:
return sema.BlockType

case PrimitiveStaticTypeStorable:
return sema.StorableType

// Number

case PrimitiveStaticTypeNumber:
Expand Down Expand Up @@ -881,6 +885,8 @@ func ConvertSemaToPrimitiveStaticType(
typ = PrimitiveStaticTypeStorageCapabilityController
case sema.AccountCapabilityControllerType:
typ = PrimitiveStaticTypeAccountCapabilityController
case sema.StorableType:
typ = PrimitiveStaticTypeStorable

case sema.AccountType:
typ = PrimitiveStaticTypeAccount
Expand Down
188 changes: 95 additions & 93 deletions interpreter/primitivestatictype_string.go

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

17 changes: 10 additions & 7 deletions interpreter/statictype.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (t InclusiveRangeStaticType) BaseType() StaticType {
if t.ElementType == nil {
return nil
}
return &InclusiveRangeStaticType{}
return InclusiveRangeStaticType{}
}

func (t InclusiveRangeStaticType) TypeArguments() []StaticType {
Expand Down Expand Up @@ -1357,12 +1357,15 @@ func ConvertStaticToSemaType(
), nil

case InclusiveRangeStaticType:
elementType, err := ConvertStaticToSemaType(
context,
t.ElementType,
)
if err != nil {
return nil, err
var elementType sema.Type
if t.ElementType != nil {
elementType, err = ConvertStaticToSemaType(
context,
t.ElementType,
)
if err != nil {
return nil, err
}
}

return sema.NewInclusiveRangeType(
Expand Down
5 changes: 5 additions & 0 deletions interpreter/statictype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,11 @@ func TestStaticTypeConversion(t *testing.T) {
ElementType: PrimitiveStaticTypeInt,
},
},
{
name: "Storable",
semaType: sema.StorableType,
staticType: PrimitiveStaticTypeStorable,
},
// Deprecated primitive static types, only exist for migration purposes
{
name: "AuthAccount",
Expand Down
Loading
Loading