Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 3 additions & 1 deletion encoding/ccf/simpletype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func TestTypeConversion(t *testing.T) {
}

for ty := interpreter.PrimitiveStaticType(1); ty < interpreter.PrimitiveStaticType_Count; ty++ {
if !ty.IsDefined() || ty.IsDeprecated() { //nolint:staticcheck
if !ty.IsDefined() ||
ty.IsDeprecated() || //nolint:staticcheck
ty == interpreter.PrimitiveStaticTypeStorable {
Comment thread
SupunS marked this conversation as resolved.
Outdated
continue
}

Expand Down
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
9 changes: 6 additions & 3 deletions interpreter/subtype_check.gen.go

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

Loading
Loading