Skip to content

Instantly share code, notes, and snippets.

@SupunS
Created January 8, 2024 17:56
Show Gist options
  • Save SupunS/8828d8b0295a9feca9cc9c275f589062 to your computer and use it in GitHub Desktop.
Save SupunS/8828d8b0295a9feca9cc9c275f589062 to your computer and use it in GitHub Desktop.
commit 1a1595ccba3da833465d2ebc35e7ad919edb3d15
Merge: 2a2c540f3 32ddd355c
Author: Supun Setunga <supun.setunga@gmail.com>
Date: Fri Jan 5 11:27:44 2024 -0800
Merge branch 'master' of https://github.com/onflow/cadence into supun/sync-range-type
diff --git a/encoding/ccf/decode.go b/encoding/ccf/decode.go
remerge CONFLICT (content): Merge conflict in encoding/ccf/decode.go
index e6f9efe60..6a3df5b48 100644
--- a/encoding/ccf/decode.go
+++ b/encoding/ccf/decode.go
@@ -493,33 +493,6 @@ func (d *Decoder) decodeValue(t cadence.Type, types *cadenceTypeByCCFTypeID) (ca
case cadence.UFix64Type:
return d.decodeUFix64()
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- case *cadence.VariableSizedArrayType:
- return d.decodeArray(t, false, 0, types)
-
- case *cadence.ConstantSizedArrayType:
- return d.decodeArray(t, true, uint64(t.Size), types)
-
- case *cadence.DictionaryType:
- return d.decodeDictionary(t, types)
-
- case *cadence.ResourceType:
- return d.decodeResource(t, types)
-
- case *cadence.InclusiveRangeType:
- return d.decodeInclusiveRange(t, types)
-
- case *cadence.StructType:
- return d.decodeStruct(t, types)
-
- case *cadence.EventType:
- return d.decodeEvent(t, types)
-
- case *cadence.ContractType:
- return d.decodeContract(t, types)
-
-=======
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
case cadence.StoragePathType:
return d.decodePath()
@@ -577,6 +550,9 @@ func (d *Decoder) decodeValue(t cadence.Type, types *cadenceTypeByCCFTypeID) (ca
// When static type is a reference type, encoded value is its deferenced type.
return d.decodeValue(t.Type, types)
+ case *cadence.InclusiveRangeType:
+ return d.decodeInclusiveRange(t, types)
+
default:
nt, err := d.dec.NextType()
if err != nil {
diff --git a/encoding/ccf/traverse_value.go b/encoding/ccf/traverse_value.go
remerge CONFLICT (content): Merge conflict in encoding/ccf/traverse_value.go
index bd1b5d957..baed2c00a 100644
--- a/encoding/ccf/traverse_value.go
+++ b/encoding/ccf/traverse_value.go
@@ -181,7 +181,8 @@ func (ct *compositeTypes) traverseType(typ cadence.Type) (checkRuntimeType bool)
return true
case cadence.BytesType,
- *cadence.FunctionType:
+ *cadence.FunctionType,
+ *cadence.InclusiveRangeType:
// TODO: Maybe there are more types that we can skip checking runtime type for composite type.
return false
@@ -227,13 +228,8 @@ func (ct *compositeTypes) traverseType(typ cadence.Type) (checkRuntimeType bool)
cadence.SignedIntegerType,
cadence.FixedSizeUnsignedIntegerType,
cadence.FixedPointType,
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- cadence.SignedFixedPointType,
- *cadence.InclusiveRangeType:
-=======
cadence.SignedFixedPointType:
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
// TODO: Maybe there are more types that we can skip checking runtime type for composite type.
return false
diff --git a/encoding/json/decode.go b/encoding/json/decode.go
remerge CONFLICT (content): Merge conflict in encoding/json/decode.go
index 3dd8bc29e..20f2aa4af 100644
--- a/encoding/json/decode.go
+++ b/encoding/json/decode.go
@@ -112,37 +112,6 @@ func (d *Decoder) Decode() (value cadence.Value, err error) {
}
const (
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- typeKey = "type"
- kindKey = "kind"
- valueKey = "value"
- keyKey = "key"
- nameKey = "name"
- fieldsKey = "fields"
- initializersKey = "initializers"
- idKey = "id"
- targetPathKey = "targetPath"
- borrowTypeKey = "borrowType"
- domainKey = "domain"
- identifierKey = "identifier"
- staticTypeKey = "staticType"
- addressKey = "address"
- pathKey = "path"
- authorizedKey = "authorized"
- sizeKey = "size"
- typeIDKey = "typeID"
- restrictionsKey = "restrictions"
- labelKey = "label"
- parametersKey = "parameters"
- typeParametersKey = "typeParameters"
- returnKey = "return"
- typeBoundKey = "typeBound"
- functionTypeKey = "functionType"
- elementKey = "element"
- startKey = "start"
- endKey = "end"
- stepKey = "step"
-=======
typeKey = "type"
kindKey = "kind"
valueKey = "value"
@@ -170,7 +139,10 @@ const (
typeBoundKey = "typeBound"
purityKey = "purity"
functionTypeKey = "functionType"
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ elementKey = "element"
+ startKey = "start"
+ endKey = "end"
+ stepKey = "step"
)
func (d *Decoder) decodeJSON(v any) cadence.Value {
diff --git a/encoding/json/encode.go b/encoding/json/encode.go
remerge CONFLICT (content): Merge conflict in encoding/json/encode.go
index ab4babc2d..f6d9c8bc5 100644
--- a/encoding/json/encode.go
+++ b/encoding/json/encode.go
@@ -171,21 +171,9 @@ type jsonDictionaryType struct {
Kind string `json:"kind"`
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-type jsonInclusiveRangeType struct {
- ElementType jsonValue `json:"element"`
- Kind string `json:"kind"`
-}
-
-type jsonReferenceType struct {
- Type jsonValue `json:"type"`
- Kind string `json:"kind"`
- Authorized bool `json:"authorized"`
-=======
type jsonAuthorization struct {
Kind string `json:"kind"`
Entitlements []jsonNominalType `json:"entitlements"`
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
}
type jsonReferenceType struct {
@@ -234,8 +222,12 @@ type jsonFunctionValue struct {
FunctionType jsonValue `json:"functionType"`
}
+type jsonInclusiveRangeType struct {
+ ElementType jsonValue `json:"element"`
+ Kind string `json:"kind"`
+}
+
const (
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
voidTypeStr = "Void"
optionalTypeStr = "Optional"
boolTypeStr = "Bool"
@@ -271,56 +263,12 @@ const (
attachmentTypeStr = "Attachment"
eventTypeStr = "Event"
contractTypeStr = "Contract"
- inclusiveRangeTypeStr = "InclusiveRange"
- linkTypeStr = "Link"
- accountLinkTypeStr = "AccountLink"
pathTypeStr = "Path"
typeTypeStr = "Type"
capabilityTypeStr = "Capability"
enumTypeStr = "Enum"
functionTypeStr = "Function"
-=======
- voidTypeStr = "Void"
- optionalTypeStr = "Optional"
- boolTypeStr = "Bool"
- characterTypeStr = "Character"
- stringTypeStr = "String"
- addressTypeStr = "Address"
- intTypeStr = "Int"
- int8TypeStr = "Int8"
- int16TypeStr = "Int16"
- int32TypeStr = "Int32"
- int64TypeStr = "Int64"
- int128TypeStr = "Int128"
- int256TypeStr = "Int256"
- uintTypeStr = "UInt"
- uint8TypeStr = "UInt8"
- uint16TypeStr = "UInt16"
- uint32TypeStr = "UInt32"
- uint64TypeStr = "UInt64"
- uint128TypeStr = "UInt128"
- uint256TypeStr = "UInt256"
- word8TypeStr = "Word8"
- word16TypeStr = "Word16"
- word32TypeStr = "Word32"
- word64TypeStr = "Word64"
- word128TypeStr = "Word128"
- word256TypeStr = "Word256"
- fix64TypeStr = "Fix64"
- ufix64TypeStr = "UFix64"
- arrayTypeStr = "Array"
- dictionaryTypeStr = "Dictionary"
- structTypeStr = "Struct"
- resourceTypeStr = "Resource"
- attachmentTypeStr = "Attachment"
- eventTypeStr = "Event"
- contractTypeStr = "Contract"
- pathTypeStr = "Path"
- typeTypeStr = "Type"
- capabilityTypeStr = "Capability"
- enumTypeStr = "Enum"
- functionTypeStr = "Function"
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ inclusiveRangeTypeStr = "InclusiveRange"
)
// Prepare traverses the object graph of the provided value and constructs
diff --git a/runtime/common/memorykind_string.go b/runtime/common/memorykind_string.go
remerge CONFLICT (content): Merge conflict in runtime/common/memorykind_string.go
index 2b172f44f..6790aa4a2 100644
--- a/runtime/common/memorykind_string.go
+++ b/runtime/common/memorykind_string.go
@@ -20,198 +20,6 @@ func _() {
_ = x[MemoryKindOptionalValue-9]
_ = x[MemoryKindTypeValue-10]
_ = x[MemoryKindPathValue-11]
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- _ = x[MemoryKindIDCapabilityValue-12]
- _ = x[MemoryKindPathCapabilityValue-13]
- _ = x[MemoryKindPathLinkValue-14]
- _ = x[MemoryKindAccountLinkValue-15]
- _ = x[MemoryKindStorageReferenceValue-16]
- _ = x[MemoryKindAccountReferenceValue-17]
- _ = x[MemoryKindEphemeralReferenceValue-18]
- _ = x[MemoryKindInterpretedFunctionValue-19]
- _ = x[MemoryKindHostFunctionValue-20]
- _ = x[MemoryKindBoundFunctionValue-21]
- _ = x[MemoryKindBigInt-22]
- _ = x[MemoryKindSimpleCompositeValue-23]
- _ = x[MemoryKindPublishedValue-24]
- _ = x[MemoryKindStorageCapabilityControllerValue-25]
- _ = x[MemoryKindAccountCapabilityControllerValue-26]
- _ = x[MemoryKindAtreeArrayDataSlab-27]
- _ = x[MemoryKindAtreeArrayMetaDataSlab-28]
- _ = x[MemoryKindAtreeArrayElementOverhead-29]
- _ = x[MemoryKindAtreeMapDataSlab-30]
- _ = x[MemoryKindAtreeMapMetaDataSlab-31]
- _ = x[MemoryKindAtreeMapElementOverhead-32]
- _ = x[MemoryKindAtreeMapPreAllocatedElement-33]
- _ = x[MemoryKindAtreeEncodedSlab-34]
- _ = x[MemoryKindPrimitiveStaticType-35]
- _ = x[MemoryKindCompositeStaticType-36]
- _ = x[MemoryKindInterfaceStaticType-37]
- _ = x[MemoryKindVariableSizedStaticType-38]
- _ = x[MemoryKindConstantSizedStaticType-39]
- _ = x[MemoryKindDictionaryStaticType-40]
- _ = x[MemoryKindInclusiveRangeStaticType-41]
- _ = x[MemoryKindOptionalStaticType-42]
- _ = x[MemoryKindRestrictedStaticType-43]
- _ = x[MemoryKindReferenceStaticType-44]
- _ = x[MemoryKindCapabilityStaticType-45]
- _ = x[MemoryKindFunctionStaticType-46]
- _ = x[MemoryKindCadenceVoidValue-47]
- _ = x[MemoryKindCadenceOptionalValue-48]
- _ = x[MemoryKindCadenceBoolValue-49]
- _ = x[MemoryKindCadenceStringValue-50]
- _ = x[MemoryKindCadenceCharacterValue-51]
- _ = x[MemoryKindCadenceAddressValue-52]
- _ = x[MemoryKindCadenceIntValue-53]
- _ = x[MemoryKindCadenceNumberValue-54]
- _ = x[MemoryKindCadenceArrayValueBase-55]
- _ = x[MemoryKindCadenceArrayValueLength-56]
- _ = x[MemoryKindCadenceDictionaryValue-57]
- _ = x[MemoryKindCadenceInclusiveRangeValue-58]
- _ = x[MemoryKindCadenceKeyValuePair-59]
- _ = x[MemoryKindCadenceStructValueBase-60]
- _ = x[MemoryKindCadenceStructValueSize-61]
- _ = x[MemoryKindCadenceResourceValueBase-62]
- _ = x[MemoryKindCadenceAttachmentValueBase-63]
- _ = x[MemoryKindCadenceResourceValueSize-64]
- _ = x[MemoryKindCadenceAttachmentValueSize-65]
- _ = x[MemoryKindCadenceEventValueBase-66]
- _ = x[MemoryKindCadenceEventValueSize-67]
- _ = x[MemoryKindCadenceContractValueBase-68]
- _ = x[MemoryKindCadenceContractValueSize-69]
- _ = x[MemoryKindCadenceEnumValueBase-70]
- _ = x[MemoryKindCadenceEnumValueSize-71]
- _ = x[MemoryKindCadencePathLinkValue-72]
- _ = x[MemoryKindCadenceAccountLinkValue-73]
- _ = x[MemoryKindCadencePathValue-74]
- _ = x[MemoryKindCadenceTypeValue-75]
- _ = x[MemoryKindCadenceIDCapabilityValue-76]
- _ = x[MemoryKindCadencePathCapabilityValue-77]
- _ = x[MemoryKindCadenceFunctionValue-78]
- _ = x[MemoryKindCadenceOptionalType-79]
- _ = x[MemoryKindCadenceVariableSizedArrayType-80]
- _ = x[MemoryKindCadenceConstantSizedArrayType-81]
- _ = x[MemoryKindCadenceDictionaryType-82]
- _ = x[MemoryKindCadenceInclusiveRangeType-83]
- _ = x[MemoryKindCadenceField-84]
- _ = x[MemoryKindCadenceParameter-85]
- _ = x[MemoryKindCadenceTypeParameter-86]
- _ = x[MemoryKindCadenceStructType-87]
- _ = x[MemoryKindCadenceResourceType-88]
- _ = x[MemoryKindCadenceAttachmentType-89]
- _ = x[MemoryKindCadenceEventType-90]
- _ = x[MemoryKindCadenceContractType-91]
- _ = x[MemoryKindCadenceStructInterfaceType-92]
- _ = x[MemoryKindCadenceResourceInterfaceType-93]
- _ = x[MemoryKindCadenceContractInterfaceType-94]
- _ = x[MemoryKindCadenceFunctionType-95]
- _ = x[MemoryKindCadenceReferenceType-96]
- _ = x[MemoryKindCadenceRestrictedType-97]
- _ = x[MemoryKindCadenceCapabilityType-98]
- _ = x[MemoryKindCadenceEnumType-99]
- _ = x[MemoryKindRawString-100]
- _ = x[MemoryKindAddressLocation-101]
- _ = x[MemoryKindBytes-102]
- _ = x[MemoryKindVariable-103]
- _ = x[MemoryKindCompositeTypeInfo-104]
- _ = x[MemoryKindCompositeField-105]
- _ = x[MemoryKindInvocation-106]
- _ = x[MemoryKindStorageMap-107]
- _ = x[MemoryKindStorageKey-108]
- _ = x[MemoryKindTypeToken-109]
- _ = x[MemoryKindErrorToken-110]
- _ = x[MemoryKindSpaceToken-111]
- _ = x[MemoryKindProgram-112]
- _ = x[MemoryKindIdentifier-113]
- _ = x[MemoryKindArgument-114]
- _ = x[MemoryKindBlock-115]
- _ = x[MemoryKindFunctionBlock-116]
- _ = x[MemoryKindParameter-117]
- _ = x[MemoryKindParameterList-118]
- _ = x[MemoryKindTypeParameter-119]
- _ = x[MemoryKindTypeParameterList-120]
- _ = x[MemoryKindTransfer-121]
- _ = x[MemoryKindMembers-122]
- _ = x[MemoryKindTypeAnnotation-123]
- _ = x[MemoryKindDictionaryEntry-124]
- _ = x[MemoryKindFunctionDeclaration-125]
- _ = x[MemoryKindCompositeDeclaration-126]
- _ = x[MemoryKindAttachmentDeclaration-127]
- _ = x[MemoryKindInterfaceDeclaration-128]
- _ = x[MemoryKindEnumCaseDeclaration-129]
- _ = x[MemoryKindFieldDeclaration-130]
- _ = x[MemoryKindTransactionDeclaration-131]
- _ = x[MemoryKindImportDeclaration-132]
- _ = x[MemoryKindVariableDeclaration-133]
- _ = x[MemoryKindSpecialFunctionDeclaration-134]
- _ = x[MemoryKindPragmaDeclaration-135]
- _ = x[MemoryKindAssignmentStatement-136]
- _ = x[MemoryKindBreakStatement-137]
- _ = x[MemoryKindContinueStatement-138]
- _ = x[MemoryKindEmitStatement-139]
- _ = x[MemoryKindExpressionStatement-140]
- _ = x[MemoryKindForStatement-141]
- _ = x[MemoryKindIfStatement-142]
- _ = x[MemoryKindReturnStatement-143]
- _ = x[MemoryKindSwapStatement-144]
- _ = x[MemoryKindSwitchStatement-145]
- _ = x[MemoryKindWhileStatement-146]
- _ = x[MemoryKindRemoveStatement-147]
- _ = x[MemoryKindBooleanExpression-148]
- _ = x[MemoryKindVoidExpression-149]
- _ = x[MemoryKindNilExpression-150]
- _ = x[MemoryKindStringExpression-151]
- _ = x[MemoryKindIntegerExpression-152]
- _ = x[MemoryKindFixedPointExpression-153]
- _ = x[MemoryKindArrayExpression-154]
- _ = x[MemoryKindDictionaryExpression-155]
- _ = x[MemoryKindIdentifierExpression-156]
- _ = x[MemoryKindInvocationExpression-157]
- _ = x[MemoryKindMemberExpression-158]
- _ = x[MemoryKindIndexExpression-159]
- _ = x[MemoryKindConditionalExpression-160]
- _ = x[MemoryKindUnaryExpression-161]
- _ = x[MemoryKindBinaryExpression-162]
- _ = x[MemoryKindFunctionExpression-163]
- _ = x[MemoryKindCastingExpression-164]
- _ = x[MemoryKindCreateExpression-165]
- _ = x[MemoryKindDestroyExpression-166]
- _ = x[MemoryKindReferenceExpression-167]
- _ = x[MemoryKindForceExpression-168]
- _ = x[MemoryKindPathExpression-169]
- _ = x[MemoryKindAttachExpression-170]
- _ = x[MemoryKindConstantSizedType-171]
- _ = x[MemoryKindDictionaryType-172]
- _ = x[MemoryKindFunctionType-173]
- _ = x[MemoryKindInstantiationType-174]
- _ = x[MemoryKindNominalType-175]
- _ = x[MemoryKindOptionalType-176]
- _ = x[MemoryKindReferenceType-177]
- _ = x[MemoryKindRestrictedType-178]
- _ = x[MemoryKindVariableSizedType-179]
- _ = x[MemoryKindPosition-180]
- _ = x[MemoryKindRange-181]
- _ = x[MemoryKindElaboration-182]
- _ = x[MemoryKindActivation-183]
- _ = x[MemoryKindActivationEntries-184]
- _ = x[MemoryKindVariableSizedSemaType-185]
- _ = x[MemoryKindConstantSizedSemaType-186]
- _ = x[MemoryKindDictionarySemaType-187]
- _ = x[MemoryKindOptionalSemaType-188]
- _ = x[MemoryKindRestrictedSemaType-189]
- _ = x[MemoryKindReferenceSemaType-190]
- _ = x[MemoryKindCapabilitySemaType-191]
- _ = x[MemoryKindInclusiveRangeSemaType-192]
- _ = x[MemoryKindOrderedMap-193]
- _ = x[MemoryKindOrderedMapEntryList-194]
- _ = x[MemoryKindOrderedMapEntry-195]
- _ = x[MemoryKindLast-196]
-}
-
-const _MemoryKind_name = "UnknownAddressValueStringValueCharacterValueNumberValueArrayValueBaseDictionaryValueBaseCompositeValueBaseSimpleCompositeValueBaseOptionalValueTypeValuePathValueIDCapabilityValuePathCapabilityValuePathLinkValueAccountLinkValueStorageReferenceValueAccountReferenceValueEphemeralReferenceValueInterpretedFunctionValueHostFunctionValueBoundFunctionValueBigIntSimpleCompositeValuePublishedValueStorageCapabilityControllerValueAccountCapabilityControllerValueAtreeArrayDataSlabAtreeArrayMetaDataSlabAtreeArrayElementOverheadAtreeMapDataSlabAtreeMapMetaDataSlabAtreeMapElementOverheadAtreeMapPreAllocatedElementAtreeEncodedSlabPrimitiveStaticTypeCompositeStaticTypeInterfaceStaticTypeVariableSizedStaticTypeConstantSizedStaticTypeDictionaryStaticTypeInclusiveRangeStaticTypeOptionalStaticTypeRestrictedStaticTypeReferenceStaticTypeCapabilityStaticTypeFunctionStaticTypeCadenceVoidValueCadenceOptionalValueCadenceBoolValueCadenceStringValueCadenceCharacterValueCadenceAddressValueCadenceIntValueCadenceNumberValueCadenceArrayValueBaseCadenceArrayValueLengthCadenceDictionaryValueCadenceInclusiveRangeValueCadenceKeyValuePairCadenceStructValueBaseCadenceStructValueSizeCadenceResourceValueBaseCadenceAttachmentValueBaseCadenceResourceValueSizeCadenceAttachmentValueSizeCadenceEventValueBaseCadenceEventValueSizeCadenceContractValueBaseCadenceContractValueSizeCadenceEnumValueBaseCadenceEnumValueSizeCadencePathLinkValueCadenceAccountLinkValueCadencePathValueCadenceTypeValueCadenceIDCapabilityValueCadencePathCapabilityValueCadenceFunctionValueCadenceOptionalTypeCadenceVariableSizedArrayTypeCadenceConstantSizedArrayTypeCadenceDictionaryTypeCadenceInclusiveRangeTypeCadenceFieldCadenceParameterCadenceTypeParameterCadenceStructTypeCadenceResourceTypeCadenceAttachmentTypeCadenceEventTypeCadenceContractTypeCadenceStructInterfaceTypeCadenceResourceInterfaceTypeCadenceContractInterfaceTypeCadenceFunctionTypeCadenceReferenceTypeCadenceRestrictedTypeCadenceCapabilityTypeCadenceEnumTypeRawStringAddressLocationBytesVariableCompositeTypeInfoCompositeFieldInvocationStorageMapStorageKeyTypeTokenErrorTokenSpaceTokenProgramIdentifierArgumentBlockFunctionBlockParameterParameterListTypeParameterTypeParameterListTransferMembersTypeAnnotationDictionaryEntryFunctionDeclarationCompositeDeclarationAttachmentDeclarationInterfaceDeclarationEnumCaseDeclarationFieldDeclarationTransactionDeclarationImportDeclarationVariableDeclarationSpecialFunctionDeclarationPragmaDeclarationAssignmentStatementBreakStatementContinueStatementEmitStatementExpressionStatementForStatementIfStatementReturnStatementSwapStatementSwitchStatementWhileStatementRemoveStatementBooleanExpressionVoidExpressionNilExpressionStringExpressionIntegerExpressionFixedPointExpressionArrayExpressionDictionaryExpressionIdentifierExpressionInvocationExpressionMemberExpressionIndexExpressionConditionalExpressionUnaryExpressionBinaryExpressionFunctionExpressionCastingExpressionCreateExpressionDestroyExpressionReferenceExpressionForceExpressionPathExpressionAttachExpressionConstantSizedTypeDictionaryTypeFunctionTypeInstantiationTypeNominalTypeOptionalTypeReferenceTypeRestrictedTypeVariableSizedTypePositionRangeElaborationActivationActivationEntriesVariableSizedSemaTypeConstantSizedSemaTypeDictionarySemaTypeOptionalSemaTypeRestrictedSemaTypeReferenceSemaTypeCapabilitySemaTypeInclusiveRangeSemaTypeOrderedMapOrderedMapEntryListOrderedMapEntryLast"
-
-var _MemoryKind_index = [...]uint16{0, 7, 19, 30, 44, 55, 69, 88, 106, 130, 143, 152, 161, 178, 197, 210, 226, 247, 268, 291, 315, 332, 350, 356, 376, 390, 422, 454, 472, 494, 519, 535, 555, 578, 605, 621, 640, 659, 678, 701, 724, 744, 768, 786, 806, 825, 845, 863, 879, 899, 915, 933, 954, 973, 988, 1006, 1027, 1050, 1072, 1098, 1117, 1139, 1161, 1185, 1211, 1235, 1261, 1282, 1303, 1327, 1351, 1371, 1391, 1411, 1434, 1450, 1466, 1490, 1516, 1536, 1555, 1584, 1613, 1634, 1659, 1671, 1687, 1707, 1724, 1743, 1764, 1780, 1799, 1825, 1853, 1881, 1900, 1920, 1941, 1962, 1977, 1986, 2001, 2006, 2014, 2031, 2045, 2055, 2065, 2075, 2084, 2094, 2104, 2111, 2121, 2129, 2134, 2147, 2156, 2169, 2182, 2199, 2207, 2214, 2228, 2243, 2262, 2282, 2303, 2323, 2342, 2358, 2380, 2397, 2416, 2442, 2459, 2478, 2492, 2509, 2522, 2541, 2553, 2564, 2579, 2592, 2607, 2621, 2636, 2653, 2667, 2680, 2696, 2713, 2733, 2748, 2768, 2788, 2808, 2824, 2839, 2860, 2875, 2891, 2909, 2926, 2942, 2959, 2978, 2993, 3007, 3023, 3040, 3054, 3066, 3083, 3094, 3106, 3119, 3133, 3150, 3158, 3163, 3174, 3184, 3201, 3222, 3243, 3261, 3277, 3295, 3312, 3330, 3352, 3362, 3381, 3396, 3400}
-=======
_ = x[MemoryKindCapabilityValue-12]
_ = x[MemoryKindStorageReferenceValue-13]
_ = x[MemoryKindEphemeralReferenceValue-14]
@@ -401,7 +209,6 @@ var _MemoryKind_index = [...]uint16{0, 7, 19, 30, 44, 55, 69, 88, 106, 130, 143,
const _MemoryKind_name = "UnknownAddressValueStringValueCharacterValueNumberValueArrayValueBaseDictionaryValueBaseCompositeValueBaseSimpleCompositeValueBaseOptionalValueTypeValuePathValueCapabilityValueStorageReferenceValueEphemeralReferenceValueInterpretedFunctionValueHostFunctionValueBoundFunctionValueBigIntSimpleCompositeValuePublishedValueStorageCapabilityControllerValueAccountCapabilityControllerValueAtreeArrayDataSlabAtreeArrayMetaDataSlabAtreeArrayElementOverheadAtreeMapDataSlabAtreeMapMetaDataSlabAtreeMapElementOverheadAtreeMapPreAllocatedElementAtreeEncodedSlabPrimitiveStaticTypeCompositeStaticTypeInterfaceStaticTypeVariableSizedStaticTypeConstantSizedStaticTypeDictionaryStaticTypeOptionalStaticTypeIntersectionStaticTypeEntitlementSetStaticAccessEntitlementMapStaticAccessReferenceStaticTypeCapabilityStaticTypeFunctionStaticTypeCadenceVoidValueCadenceOptionalValueCadenceBoolValueCadenceStringValueCadenceCharacterValueCadenceAddressValueCadenceIntValueCadenceNumberValueCadenceArrayValueBaseCadenceArrayValueLengthCadenceDictionaryValueCadenceKeyValuePairCadenceStructValueBaseCadenceStructValueSizeCadenceResourceValueBaseCadenceAttachmentValueBaseCadenceResourceValueSizeCadenceAttachmentValueSizeCadenceEventValueBaseCadenceEventValueSizeCadenceContractValueBaseCadenceContractValueSizeCadenceEnumValueBaseCadenceEnumValueSizeCadencePathValueCadenceTypeValueCadenceCapabilityValueCadenceFunctionValueCadenceOptionalTypeCadenceVariableSizedArrayTypeCadenceConstantSizedArrayTypeCadenceDictionaryTypeCadenceFieldCadenceParameterCadenceTypeParameterCadenceStructTypeCadenceResourceTypeCadenceAttachmentTypeCadenceEventTypeCadenceContractTypeCadenceStructInterfaceTypeCadenceResourceInterfaceTypeCadenceContractInterfaceTypeCadenceFunctionTypeCadenceEntitlementSetAccessCadenceEntitlementMapAccessCadenceReferenceTypeCadenceIntersectionTypeCadenceCapabilityTypeCadenceEnumTypeRawStringAddressLocationBytesVariableCompositeTypeInfoCompositeFieldInvocationStorageMapStorageKeyTypeTokenErrorTokenSpaceTokenProgramIdentifierArgumentBlockFunctionBlockParameterParameterListTypeParameterTypeParameterListTransferMembersTypeAnnotationDictionaryEntryFunctionDeclarationCompositeDeclarationAttachmentDeclarationInterfaceDeclarationEntitlementDeclarationEntitlementMappingElementEntitlementMappingDeclarationEnumCaseDeclarationFieldDeclarationTransactionDeclarationImportDeclarationVariableDeclarationSpecialFunctionDeclarationPragmaDeclarationAssignmentStatementBreakStatementContinueStatementEmitStatementExpressionStatementForStatementIfStatementReturnStatementSwapStatementSwitchStatementWhileStatementRemoveStatementBooleanExpressionVoidExpressionNilExpressionStringExpressionIntegerExpressionFixedPointExpressionArrayExpressionDictionaryExpressionIdentifierExpressionInvocationExpressionMemberExpressionIndexExpressionConditionalExpressionUnaryExpressionBinaryExpressionFunctionExpressionCastingExpressionCreateExpressionDestroyExpressionReferenceExpressionForceExpressionPathExpressionAttachExpressionConstantSizedTypeDictionaryTypeFunctionTypeInstantiationTypeNominalTypeOptionalTypeReferenceTypeIntersectionTypeVariableSizedTypePositionRangeElaborationActivationActivationEntriesVariableSizedSemaTypeConstantSizedSemaTypeDictionarySemaTypeOptionalSemaTypeIntersectionSemaTypeReferenceSemaTypeEntitlementSemaTypeEntitlementMapSemaTypeEntitlementRelationSemaTypeCapabilitySemaTypeOrderedMapOrderedMapEntryListOrderedMapEntryLast"
var _MemoryKind_index = [...]uint16{0, 7, 19, 30, 44, 55, 69, 88, 106, 130, 143, 152, 161, 176, 197, 220, 244, 261, 279, 285, 305, 319, 351, 383, 401, 423, 448, 464, 484, 507, 534, 550, 569, 588, 607, 630, 653, 673, 691, 713, 739, 765, 784, 804, 822, 838, 858, 874, 892, 913, 932, 947, 965, 986, 1009, 1031, 1050, 1072, 1094, 1118, 1144, 1168, 1194, 1215, 1236, 1260, 1284, 1304, 1324, 1340, 1356, 1378, 1398, 1417, 1446, 1475, 1496, 1508, 1524, 1544, 1561, 1580, 1601, 1617, 1636, 1662, 1690, 1718, 1737, 1764, 1791, 1811, 1834, 1855, 1870, 1879, 1894, 1899, 1907, 1924, 1938, 1948, 1958, 1968, 1977, 1987, 1997, 2004, 2014, 2022, 2027, 2040, 2049, 2062, 2075, 2092, 2100, 2107, 2121, 2136, 2155, 2175, 2196, 2216, 2238, 2263, 2292, 2311, 2327, 2349, 2366, 2385, 2411, 2428, 2447, 2461, 2478, 2491, 2510, 2522, 2533, 2548, 2561, 2576, 2590, 2605, 2622, 2636, 2649, 2665, 2682, 2702, 2717, 2737, 2757, 2777, 2793, 2808, 2829, 2844, 2860, 2878, 2895, 2911, 2928, 2947, 2962, 2976, 2992, 3009, 3023, 3035, 3052, 3063, 3075, 3088, 3104, 3121, 3129, 3134, 3145, 3155, 3172, 3193, 3214, 3232, 3248, 3268, 3285, 3304, 3326, 3353, 3371, 3381, 3400, 3415, 3419}
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
func (i MemoryKind) String() string {
if i >= MemoryKind(len(_MemoryKind_index)-1) {
diff --git a/runtime/common/metering.go b/runtime/common/metering.go
remerge CONFLICT (content): Merge conflict in runtime/common/metering.go
index 7dd16cdca..de0879c8e 100644
--- a/runtime/common/metering.go
+++ b/runtime/common/metering.go
@@ -164,31 +164,14 @@ var (
VariableSizedStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindVariableSizedStaticType)
ConstantSizedStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindConstantSizedStaticType)
DictionaryStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindDictionaryStaticType)
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- InclusiveRangeStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindInclusiveRangeStaticType)
- OptionalStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindOptionalStaticType)
- RestrictedStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindRestrictedStaticType)
- ReferenceStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindReferenceStaticType)
- CapabilityStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindCapabilityStaticType)
- FunctionStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindFunctionStaticType)
-
- // Sema types
-
- VariableSizedSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindVariableSizedSemaType)
- ConstantSizedSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindConstantSizedSemaType)
- DictionarySemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindDictionarySemaType)
- InclusiveRangeSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindInclusiveRangeSemaType)
- OptionalSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindOptionalSemaType)
- RestrictedSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindRestrictedSemaType)
- ReferenceSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindReferenceSemaType)
- CapabilitySemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindCapabilitySemaType)
-=======
OptionalStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindOptionalStaticType)
IntersectionStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindIntersectionStaticType)
ReferenceStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindReferenceStaticType)
CapabilityStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindCapabilityStaticType)
FunctionStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindFunctionStaticType)
EntitlementMapStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindEntitlementMapStaticAccess)
+ InclusiveRangeStaticTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindInclusiveRangeStaticType)
+
// Sema types
VariableSizedSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindVariableSizedSemaType)
@@ -201,7 +184,7 @@ var (
EntitlementMapSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindEntitlementMapSemaType)
EntitlementRelationSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindEntitlementRelationSemaType)
CapabilitySemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindCapabilitySemaType)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ InclusiveRangeSemaTypeMemoryUsage = NewConstantMemoryUsage(MemoryKindInclusiveRangeSemaType)
// Storage related memory usages
@@ -280,22 +263,13 @@ var (
// Static types string representations
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- VariableSizedStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(2) // []
- DictionaryStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(4) // {: }
- InclusiveRangeStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(16) // InclusiveRange<>
- OptionalStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(1) // ?
- AuthReferenceStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(5) // auth&
- ReferenceStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(1) // &
- CapabilityStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(12) // Capability<>
-=======
VariableSizedStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(2) // []
DictionaryStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(4) // {: }
OptionalStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(1) // ?
CapabilityStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(12) // Capability<>
IntersectionStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(2) // {}
IntersectionStaticTypeSeparatorStringMemoryUsage = NewRawStringMemoryUsage(2) // ,
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ InclusiveRangeStaticTypeStringMemoryUsage = NewRawStringMemoryUsage(16) // InclusiveRange<>
)
func UseMemory(gauge MemoryGauge, usage MemoryUsage) {
diff --git a/runtime/convertTypes.go b/runtime/convertTypes.go
remerge CONFLICT (content): Merge conflict in runtime/convertTypes.go
index 8a0e49b7e..441eea8b0 100644
--- a/runtime/convertTypes.go
+++ b/runtime/convertTypes.go
@@ -248,8 +248,6 @@ func ExportMeteredType(
return exportInterfaceType(gauge, t, results)
case *sema.DictionaryType:
return exportDictionaryType(gauge, t, results)
- case *sema.InclusiveRangeType:
- return exportInclusiveRangeType(gauge, t, results)
case *sema.FunctionType:
return exportFunctionType(gauge, t, results)
case *sema.AddressType:
@@ -260,6 +258,8 @@ func ExportMeteredType(
return exportIntersectionType(gauge, t, results)
case *sema.CapabilityType:
return exportCapabilityType(gauge, t, results)
+ case *sema.InclusiveRangeType:
+ return exportInclusiveRangeType(gauge, t, results)
}
panic(fmt.Sprintf("cannot export type %s", t))
@@ -706,12 +706,11 @@ func ImportType(memoryGauge common.MemoryGauge, t cadence.Type) interpreter.Stat
ImportType(memoryGauge, t.KeyType),
ImportType(memoryGauge, t.ElementType),
)
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
case *cadence.InclusiveRangeType:
- return interpreter.NewInclusiveRangeStaticType(memoryGauge, ImportType(memoryGauge, t.ElementType))
-=======
-
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ return interpreter.NewInclusiveRangeStaticType(
+ memoryGauge,
+ ImportType(memoryGauge, t.ElementType),
+ )
case *cadence.StructType,
*cadence.ResourceType,
*cadence.EventType,
diff --git a/runtime/convertValues.go b/runtime/convertValues.go
remerge CONFLICT (content): Merge conflict in runtime/convertValues.go
index 3ab71101d..d460e9ddb 100644
--- a/runtime/convertValues.go
+++ b/runtime/convertValues.go
@@ -606,7 +606,6 @@ func exportDictionaryValue(
return dictionary.WithType(exportType), err
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
func exportCompositeValueAsInclusiveRange(
v interpreter.Value,
inclusiveRangeType *sema.InclusiveRangeType,
@@ -677,8 +676,6 @@ func exportAccountLinkValue(inter *interpreter.Interpreter) cadence.AccountLink
return cadence.NewMeteredAccountLink(inter)
}
-=======
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
func exportPathValue(gauge common.MemoryGauge, v interpreter.PathValue) (cadence.Path, error) {
return cadence.NewMeteredPath(
gauge,
diff --git a/runtime/convertValues_test.go b/runtime/convertValues_test.go
remerge CONFLICT (content): Merge conflict in runtime/convertValues_test.go
index d3c6e46b4..e0d8d3c6e 100644
--- a/runtime/convertValues_test.go
+++ b/runtime/convertValues_test.go
@@ -1254,20 +1254,7 @@ func TestRuntimeImportRuntimeType(t *testing.T) {
},
},
{
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- label: "InclusiveRange",
- actual: &cadence.InclusiveRangeType{
- ElementType: cadence.IntType{},
- },
- expected: interpreter.InclusiveRangeStaticType{
- ElementType: interpreter.PrimitiveStaticTypeInt,
- },
- },
- {
- label: "Reference",
-=======
label: "Unauthorized Reference",
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
actual: &cadence.ReferenceType{
Authorization: cadence.UnauthorizedAccess,
Type: cadence.IntType,
@@ -1296,9 +1283,8 @@ func TestRuntimeImportRuntimeType(t *testing.T) {
ReferencedType: interpreter.PrimitiveStaticTypeInt,
},
},
-
{
- label: "Entitlement Disjoint Set Reference",
+ label: "Reference",
actual: &cadence.ReferenceType{
Authorization: cadence.EntitlementSetAuthorization{
Kind: cadence.Disjunction,
@@ -1419,6 +1405,15 @@ func TestRuntimeImportRuntimeType(t *testing.T) {
},
},
},
+ {
+ label: "InclusiveRange",
+ actual: &cadence.InclusiveRangeType{
+ ElementType: cadence.IntType,
+ },
+ expected: interpreter.InclusiveRangeStaticType{
+ ElementType: interpreter.PrimitiveStaticTypeInt,
+ },
+ },
} {
test(tt)
}
@@ -1511,7 +1506,6 @@ func TestRuntimeExportAddressValue(t *testing.T) {
assert.Equal(t, expected, actual)
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
func TestExportInclusiveRangeValue(t *testing.T) {
t.Parallel()
@@ -1693,10 +1687,7 @@ func TestImportInclusiveRangeValue(t *testing.T) {
})
}
-func TestExportStructValue(t *testing.T) {
-=======
func TestRuntimeExportStructValue(t *testing.T) {
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
t.Parallel()
diff --git a/runtime/interpreter/decode.go b/runtime/interpreter/decode.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/decode.go
index be9a35b10..d42782b16 100644
--- a/runtime/interpreter/decode.go
+++ b/runtime/interpreter/decode.go
@@ -1436,20 +1436,15 @@ func (d TypeDecoder) DecodeStaticType() (StaticType, error) {
case CBORTagDictionaryStaticType:
return d.decodeDictionaryStaticType()
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- case CBORTagInclusiveRangeStaticType:
- return d.decodeInclusiveRangeStaticType()
-
- case CBORTagRestrictedStaticType:
- return d.decodeRestrictedStaticType()
-=======
case CBORTagIntersectionStaticType:
return d.decodeIntersectionStaticType()
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
case CBORTagCapabilityStaticType:
return d.decodeCapabilityStaticType()
+ case CBORTagInclusiveRangeStaticType:
+ return d.decodeInclusiveRangeStaticType()
+
default:
return nil, errors.NewUnexpectedError("invalid static type encoding tag: %d", number)
}
@@ -1861,24 +1856,8 @@ func (d TypeDecoder) decodeDictionaryStaticType() (StaticType, error) {
return NewDictionaryStaticType(d.memoryGauge, keyType, valueType), nil
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-func (d TypeDecoder) decodeInclusiveRangeStaticType() (StaticType, error) {
- elementType, err := d.DecodeStaticType()
- if err != nil {
- return nil, errors.NewUnexpectedError(
- "invalid inclusive range static type encoding: %w",
- err,
- )
- }
- return NewInclusiveRangeStaticType(d.memoryGauge, elementType), nil
-}
-
-func (d TypeDecoder) decodeRestrictedStaticType() (StaticType, error) {
- const expectedLength = encodedRestrictedStaticTypeLength
-=======
func (d TypeDecoder) decodeIntersectionStaticType() (StaticType, error) {
const expectedLength = encodedIntersectionStaticTypeLength
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
arraySize, err := d.decoder.DecodeArrayHead()
@@ -2050,6 +2029,17 @@ func (d TypeDecoder) decodeCompositeTypeInfo() (atree.TypeInfo, error) {
), nil
}
+func (d TypeDecoder) decodeInclusiveRangeStaticType() (StaticType, error) {
+ elementType, err := d.DecodeStaticType()
+ if err != nil {
+ return nil, errors.NewUnexpectedError(
+ "invalid inclusive range static type encoding: %w",
+ err,
+ )
+ }
+ return NewInclusiveRangeStaticType(d.memoryGauge, elementType), nil
+}
+
func DecodeTypeInfo(decoder *cbor.StreamDecoder, memoryGauge common.MemoryGauge) (atree.TypeInfo, error) {
d := NewTypeDecoder(decoder, memoryGauge)
diff --git a/runtime/interpreter/encode.go b/runtime/interpreter/encode.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/encode.go
index 79cc4d216..198ecd0e8 100644
--- a/runtime/interpreter/encode.go
+++ b/runtime/interpreter/encode.go
@@ -221,13 +221,10 @@ const (
CBORTagReferenceStaticType
CBORTagIntersectionStaticType
CBORTagCapabilityStaticType
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- CBORTagInclusiveRangeStaticType
-=======
CBORTagUnauthorizedStaticAuthorization
CBORTagEntitlementMapStaticAuthorization
CBORTagEntitlementSetStaticAuthorization
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ CBORTagInclusiveRangeStaticType
// !!! *WARNING* !!!
// ADD NEW TYPES *BEFORE* THIS WARNING.
diff --git a/runtime/interpreter/encoding_test.go b/runtime/interpreter/encoding_test.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/encoding_test.go
index e2dd8169b..23b664a53 100644
--- a/runtime/interpreter/encoding_test.go
+++ b/runtime/interpreter/encoding_test.go
@@ -3587,11 +3587,7 @@ func TestCBORTagValue(t *testing.T) {
t.Parallel()
t.Run("No new types added in between", func(t *testing.T) {
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- require.Equal(t, byte(223), byte(CBORTag_Count))
-=======
- require.Equal(t, byte(225), byte(CBORTag_Count))
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ require.Equal(t, byte(226), byte(CBORTag_Count))
})
}
diff --git a/runtime/interpreter/errors.go b/runtime/interpreter/errors.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/errors.go
index c356f5c65..ed6aac547 100644
--- a/runtime/interpreter/errors.go
+++ b/runtime/interpreter/errors.go
@@ -997,25 +997,6 @@ func WrappedExternalError(err error) error {
}
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-// InclusiveRangeConstructionError
-
-type InclusiveRangeConstructionError struct {
- LocationRange
- Message string
-}
-
-var _ errors.UserError = InclusiveRangeConstructionError{}
-
-func (InclusiveRangeConstructionError) IsUserError() {}
-
-func (e InclusiveRangeConstructionError) Error() string {
- const message = "InclusiveRange construction failed"
- if e.Message == "" {
- return message
- }
- return fmt.Sprintf("%s: %s", message, e.Message)
-=======
// CapabilityAddressPublishingError
type CapabilityAddressPublishingError struct {
LocationRange
@@ -1050,5 +1031,23 @@ func (e NestedReferenceError) Error() string {
"cannot create a nested reference to %s",
e.Value.String(),
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+}
+
+// InclusiveRangeConstructionError
+
+type InclusiveRangeConstructionError struct {
+ LocationRange
+ Message string
+}
+
+var _ errors.UserError = InclusiveRangeConstructionError{}
+
+func (InclusiveRangeConstructionError) IsUserError() {}
+
+func (e InclusiveRangeConstructionError) Error() string {
+ const message = "InclusiveRange construction failed"
+ if e.Message == "" {
+ return message
+ }
+ return fmt.Sprintf("%s: %s", message, e.Message)
}
diff --git a/runtime/interpreter/interpreter_statement.go b/runtime/interpreter/interpreter_statement.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/interpreter_statement.go
index 6fe261ffa..00cfd6eac 100644
--- a/runtime/interpreter/interpreter_statement.go
+++ b/runtime/interpreter/interpreter_statement.go
@@ -295,11 +295,7 @@ func (interpreter *Interpreter) VisitForStatement(statement *ast.ForStatement) (
panic(errors.NewUnreachableError())
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- iterator := iterable.Iterator(interpreter, locationRange)
-=======
forStmtTypes := interpreter.Program.Elaboration.ForStatementType(statement)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
var index IntValue
if statement.Index != nil {
@@ -351,18 +347,10 @@ func (interpreter *Interpreter) visitForStatementBody(
)
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- for {
- value := iterator.Next(interpreter, locationRange)
- if value == nil {
- return nil
- }
-=======
interpreter.declareVariable(
statement.Identifier.Identifier,
value,
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
result = interpreter.visitBlock(statement.Block)
diff --git a/runtime/interpreter/statictype.go b/runtime/interpreter/statictype.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/statictype.go
index 9e02de83e..a9cffc787 100644
--- a/runtime/interpreter/statictype.go
+++ b/runtime/interpreter/statictype.go
@@ -1165,7 +1165,6 @@ func ConvertStaticToSemaType(
valueType,
), nil
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
case InclusiveRangeStaticType:
elementType, err := ConvertStaticToSemaType(memoryGauge, t.ElementType, getInterface, getComposite)
if err != nil {
@@ -1177,9 +1176,6 @@ func ConvertStaticToSemaType(
elementType,
), nil
- case OptionalStaticType:
- ty, err := ConvertStaticToSemaType(memoryGauge, t.Type, getInterface, getComposite)
-=======
case *OptionalStaticType:
ty, err := ConvertStaticToSemaType(
memoryGauge,
@@ -1189,7 +1185,6 @@ func ConvertStaticToSemaType(
getEntitlement,
getEntitlementMapType,
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
if err != nil {
return nil, err
}
diff --git a/runtime/interpreter/statictype_test.go b/runtime/interpreter/statictype_test.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/statictype_test.go
index f9c11f989..10c8080bd 100644
--- a/runtime/interpreter/statictype_test.go
+++ b/runtime/interpreter/statictype_test.go
@@ -688,7 +688,6 @@ func TestDictionaryStaticType_Equal(t *testing.T) {
})
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
func TestInclusiveRangeStaticType_Equal(t *testing.T) {
t.Parallel()
@@ -739,10 +738,7 @@ func TestInclusiveRangeStaticType_Equal(t *testing.T) {
})
}
-func TestRestrictedStaticType_Equal(t *testing.T) {
-=======
func TestIntersectionStaticType_Equal(t *testing.T) {
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
t.Parallel()
@@ -1542,25 +1538,9 @@ func TestStaticTypeConversion(t *testing.T) {
},
},
{
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- name: "InclusiveRange",
- semaType: &sema.InclusiveRangeType{
- MemberType: sema.IntType,
- },
- staticType: InclusiveRangeStaticType{
- ElementType: PrimitiveStaticTypeInt,
- },
- },
- {
- name: "Restricted",
- semaType: &sema.RestrictedType{
- Type: sema.IntType,
- Restrictions: []*sema.InterfaceType{
-=======
name: "Intersection",
semaType: &sema.IntersectionType{
Types: []*sema.InterfaceType{
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
testInterfaceSemaType,
},
},
@@ -1686,6 +1666,15 @@ func TestStaticTypeConversion(t *testing.T) {
staticType: PrimitiveStaticTypeAccountKey,
semaType: nil,
},
+ {
+ name: "InclusiveRange",
+ semaType: &sema.InclusiveRangeType{
+ MemberType: sema.IntType,
+ },
+ staticType: InclusiveRangeStaticType{
+ ElementType: PrimitiveStaticTypeInt,
+ },
+ },
}
test := func(test testCase) {
diff --git a/runtime/interpreter/value.go b/runtime/interpreter/value.go
remerge CONFLICT (content): Merge conflict in runtime/interpreter/value.go
index bf9dbb93c..8e18504bc 100644
--- a/runtime/interpreter/value.go
+++ b/runtime/interpreter/value.go
@@ -236,17 +236,13 @@ type ContractValue interface {
// IterableValue is a value which can be iterated over, e.g. with a for-loop
type IterableValue interface {
Value
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
Iterator(interpreter *Interpreter, locationRange LocationRange) ValueIterator
-=======
- Iterator(interpreter *Interpreter) ValueIterator
ForEach(
interpreter *Interpreter,
elementType sema.Type,
function func(value Value) (resume bool),
locationRange LocationRange,
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
}
// ValueIterator is an iterator which returns values.
@@ -16295,17 +16291,13 @@ func (UFix64Value) Scale() int {
type FunctionOrderedMap = orderedmap.OrderedMap[string, FunctionValue]
type CompositeValue struct {
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- Destructor FunctionValue
Location common.Location
// note that the staticType is not guaranteed to be a CompositeStaticType as there can be types
// which are non-composite but their values are treated as CompositeValue.
// For e.g. InclusiveRangeValue
-=======
- Location common.Location
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
staticType StaticType
+
Stringer func(gauge common.MemoryGauge, value *CompositeValue, seenReferences SeenReferences) string
injectedFields map[string]Value
computedFields map[string]ComputedField
@@ -17195,16 +17187,11 @@ func (v *CompositeValue) ConformsToStaticType(
}()
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
staticType := v.StaticType(interpreter)
-=======
- staticType := v.StaticType(interpreter).(*CompositeStaticType)
-
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
semaType := interpreter.MustConvertStaticToSemaType(staticType)
switch staticType.(type) {
- case CompositeStaticType:
+ case *CompositeStaticType:
return v.CompositeStaticTypeConformsToStaticType(interpreter, locationRange, results, semaType)
// CompositeValue is also used for storing types which aren't CompositeStaticType.
diff --git a/runtime/program_params_validation_test.go b/runtime/program_params_validation_test.go
remerge CONFLICT (content): Merge conflict in runtime/program_params_validation_test.go
index 37104161c..b8c6b0c8d 100644
--- a/runtime/program_params_validation_test.go
+++ b/runtime/program_params_validation_test.go
@@ -31,10 +31,7 @@ import (
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/sema"
"github.com/onflow/cadence/runtime/tests/checker"
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-=======
. "github.com/onflow/cadence/runtime/tests/runtime_utils"
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
. "github.com/onflow/cadence/runtime/tests/utils"
)
diff --git a/runtime/sema/check_for.go b/runtime/sema/check_for.go
remerge CONFLICT (content): Merge conflict in runtime/sema/check_for.go
index 7def8f2ef..31c9e1d92 100644
--- a/runtime/sema/check_for.go
+++ b/runtime/sema/check_for.go
@@ -43,45 +43,11 @@ func (checker *Checker) VisitForStatement(statement *ast.ForStatement) (_ struct
valueType := checker.VisitExpression(valueExpression, expectedType)
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- var elementType Type = InvalidType
-
- if !valueType.IsInvalidType() {
-
- // Only get the element type if the array is not a resource array.
- // Otherwise, in addition to the `UnsupportedResourceForLoopError`,
- // the loop variable will be declared with the resource-typed element type,
- // leading to an additional `ResourceLossError`.
-
- if valueType.IsResourceType() {
- checker.report(
- &UnsupportedResourceForLoopError{
- Range: ast.NewRangeFromPositioned(checker.memoryGauge, valueExpression),
- },
- )
- } else if arrayType, ok := valueType.(ArrayType); ok {
- elementType = arrayType.ElementType(false)
- } else if valueType == StringType {
- elementType = CharacterType
- } else if inclusiveRangeType, ok := valueType.(*InclusiveRangeType); ok {
- elementType = inclusiveRangeType.MemberType
- } else {
- checker.report(
- &TypeMismatchWithDescriptionError{
- ExpectedTypeDescription: "array",
- ActualType: valueType,
- Range: ast.NewRangeFromPositioned(checker.memoryGauge, valueExpression),
- },
- )
- }
- }
-=======
// Only get the element type if the array is not a resource array.
// Otherwise, in addition to the `UnsupportedResourceForLoopError`,
// the loop variable will be declared with the resource-typed element type,
// leading to an additional `ResourceLossError`.
loopVariableType := checker.loopVariableType(valueType, valueExpression)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
identifier := statement.Identifier.Identifier
@@ -188,8 +154,11 @@ func (checker *Checker) loopVariableType(valueType Type, hasPosition ast.HasPosi
}
func (checker *Checker) iterableElementType(valueType Type, hasPosition ast.HasPosition) Type {
- if arrayType, ok := valueType.(ArrayType); ok {
- return arrayType.ElementType(false)
+ switch valueType := valueType.(type) {
+ case ArrayType:
+ return valueType.ElementType(false)
+ case *InclusiveRangeType:
+ return valueType.MemberType
}
if valueType == StringType {
diff --git a/runtime/sema/type.go b/runtime/sema/type.go
remerge CONFLICT (content): Merge conflict in runtime/sema/type.go
index 276061025..7ffc4c2b8 100644
--- a/runtime/sema/type.go
+++ b/runtime/sema/type.go
@@ -204,14 +204,12 @@ type Type interface {
GetMembers() map[string]MemberResolver
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error))
-=======
// applies `f` to all the types syntactically comprising this type.
// i.e. `[T]` would map to `f([f(T)])`, but the internals of composite types are not
// inspected, as they appear simply as nominal types in annotations
Map(memoryGauge common.MemoryGauge, typeParamMap map[*TypeParameter]*TypeParameter, f func(Type) Type) Type
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+
+ CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error))
}
// ValueIndexableType is a type which can be indexed into using a value
@@ -783,16 +781,15 @@ func (t *OptionalType) Resolve(typeArguments *TypeParameterTypeOrderedMap) Type
}
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-func (t *OptionalType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
- t.Type.CheckInstantiated(pos, memoryGauge, report)
-=======
func (t *OptionalType) SupportedEntitlements() *EntitlementOrderedSet {
if entitlementSupportingType, ok := t.Type.(EntitlementSupportingType); ok {
return entitlementSupportingType.SupportedEntitlements()
}
return nil
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+}
+
+func (t *OptionalType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
+ t.Type.CheckInstantiated(pos, memoryGauge, report)
}
const optionalTypeMapFunctionDocString = `
@@ -2829,12 +2826,6 @@ func (t *VariableSizedType) Resolve(typeArguments *TypeParameterTypeOrderedMap)
}
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-func (t *VariableSizedType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
- t.ElementType(false).CheckInstantiated(pos, memoryGauge, report)
-}
-
-=======
func (t *VariableSizedType) SupportedEntitlements() *EntitlementOrderedSet {
return arrayDictionaryEntitlements
}
@@ -2847,7 +2838,10 @@ var arrayDictionaryEntitlements = func() *EntitlementOrderedSet {
return set
}()
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+func (t *VariableSizedType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
+ t.ElementType(false).CheckInstantiated(pos, memoryGauge, report)
+}
+
// ConstantSizedType is a constant sized array type
type ConstantSizedType struct {
Type Type
@@ -3017,13 +3011,12 @@ func (t *ConstantSizedType) Resolve(typeArguments *TypeParameterTypeOrderedMap)
}
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-func (t *ConstantSizedType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
- t.ElementType(false).CheckInstantiated(pos, memoryGauge, report)
-=======
func (t *ConstantSizedType) SupportedEntitlements() *EntitlementOrderedSet {
return arrayDictionaryEntitlements
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+}
+
+func (t *ConstantSizedType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
+ t.ElementType(false).CheckInstantiated(pos, memoryGauge, report)
}
// Parameter
@@ -3881,12 +3874,9 @@ func init() {
HashAlgorithmType,
StorageCapabilityControllerType,
AccountCapabilityControllerType,
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- &InclusiveRangeType{},
-=======
DeploymentResultType,
HashableStructType,
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ &InclusiveRangeType{},
},
)
@@ -3990,32 +3980,25 @@ var AllFixedSizeUnsignedIntegerTypes = []Type{
Word256Type,
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-var AllNonLeafIntegerTypes = []Type{
- IntegerType,
- SignedIntegerType,
-}
-=======
var AllUnsignedIntegerTypes = common.Concat(
AllFixedSizeUnsignedIntegerTypes,
[]Type{
UIntType,
},
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+
+var AllNonLeafIntegerTypes = []Type{
+ IntegerType,
+ SignedIntegerType,
+}
var AllIntegerTypes = common.Concat(
AllUnsignedIntegerTypes,
AllSignedIntegerTypes,
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
AllNonLeafIntegerTypes,
-=======
[]Type{
- IntegerType,
- SignedIntegerType,
FixedSizeUnsignedIntegerType,
},
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
)
var AllNumberTypes = common.Concat(
@@ -4980,26 +4963,6 @@ func (t *CompositeType) SetNestedType(name string, nestedType ContainedType) {
nestedType.SetContainerType(t)
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-func (t *CompositeType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
- if t.EnumRawType != nil {
- t.EnumRawType.CheckInstantiated(pos, memoryGauge, report)
- }
-
- if t.baseType != nil {
- t.baseType.CheckInstantiated(pos, memoryGauge, report)
- }
-
- for _, typ := range t.ImplicitTypeRequirementConformances {
- typ.CheckInstantiated(pos, memoryGauge, report)
- }
-
- for _, typ := range t.ExplicitInterfaceConformances {
- typ.CheckInstantiated(pos, memoryGauge, report)
- }
-}
-
-=======
func (t *CompositeType) ConstructorFunctionType() *FunctionType {
return &FunctionType{
IsConstructor: true,
@@ -5034,7 +4997,24 @@ func (t *CompositeType) InitializerEffectiveArgumentLabels() []string {
return argumentLabels
}
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+func (t *CompositeType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
+ if t.EnumRawType != nil {
+ t.EnumRawType.CheckInstantiated(pos, memoryGauge, report)
+ }
+
+ if t.baseType != nil {
+ t.baseType.CheckInstantiated(pos, memoryGauge, report)
+ }
+
+ for _, typ := range t.ImplicitTypeRequirementConformances {
+ typ.CheckInstantiated(pos, memoryGauge, report)
+ }
+
+ for _, typ := range t.ExplicitInterfaceConformances {
+ typ.CheckInstantiated(pos, memoryGauge, report)
+ }
+}
+
// Member
type Member struct {
@@ -5623,12 +5603,6 @@ func (t *InterfaceType) FieldPosition(name string, declaration *ast.InterfaceDec
return declaration.Members.FieldPosition(name, declaration.CompositeKind)
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-func (t *InterfaceType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
- for _, param := range t.InitializerParameters {
- param.TypeAnnotation.Type.CheckInstantiated(pos, memoryGauge, report)
- }
-=======
func (t *InterfaceType) EffectiveInterfaceConformances() []Conformance {
t.effectiveInterfaceConformancesOnce.Do(func() {
t.effectiveInterfaceConformances = distinctConformances(
@@ -5703,7 +5677,12 @@ func distinctConformances(
}
return collectedConformances
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+}
+
+func (t *InterfaceType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
+ for _, param := range t.InitializerParameters {
+ param.TypeAnnotation.Type.CheckInstantiated(pos, memoryGauge, report)
+ }
}
// DictionaryType consists of the key and value type
@@ -6167,7 +6146,10 @@ func (t *DictionaryType) Resolve(typeArguments *TypeParameterTypeOrderedMap) Typ
}
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
+func (t *DictionaryType) SupportedEntitlements() *EntitlementOrderedSet {
+ return arrayDictionaryEntitlements
+}
+
// InclusiveRangeType
type InclusiveRangeType struct {
@@ -6481,10 +6463,6 @@ func (t *InclusiveRangeType) Resolve(typeArguments *TypeParameterTypeOrderedMap)
return &InclusiveRangeType{
MemberType: memberType,
}
-=======
-func (t *DictionaryType) SupportedEntitlements() *EntitlementOrderedSet {
- return arrayDictionaryEntitlements
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
}
// ReferenceType represents the reference to a value
@@ -7497,7 +7475,6 @@ func (t *TransactionType) Resolve(_ *TypeParameterTypeOrderedMap) Type {
return t
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
func (t *TransactionType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
for _, param := range t.PrepareParameters {
param.TypeAnnotation.Type.CheckInstantiated(pos, memoryGauge, report)
@@ -7508,19 +7485,6 @@ func (t *TransactionType) CheckInstantiated(pos ast.HasPosition, memoryGauge com
}
}
-// RestrictedType
-//
-// No restrictions implies the type is fully restricted,
-// i.e. no members of the underlying resource type are available.
-type RestrictedType struct {
- Type Type
- // an internal set of field `Restrictions`
- restrictionSet *InterfaceSet
- Restrictions []*InterfaceType
- restrictionSetOnce sync.Once
- memberResolvers map[string]MemberResolver
- memberResolversOnce sync.Once
-=======
// IntersectionType
type IntersectionType struct {
@@ -7531,7 +7495,6 @@ type IntersectionType struct {
memberResolvers map[string]MemberResolver
memberResolversOnce sync.Once
supportedEntitlements *EntitlementOrderedSet
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
}
var _ Type = &IntersectionType{}
@@ -7831,7 +7794,7 @@ func (t *IntersectionType) IsValidIndexingType(ty Type) bool {
attachmentType.IsResourceType() == t.IsResourceType()
}
-func (t *RestrictedType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
+func (t *IntersectionType) CheckInstantiated(pos ast.HasPosition, memoryGauge common.MemoryGauge, report func(err error)) {
t.Type.CheckInstantiated(pos, memoryGauge, report)
}
diff --git a/runtime/sema/type_tags.go b/runtime/sema/type_tags.go
remerge CONFLICT (content): Merge conflict in runtime/sema/type_tags.go
index e61ecc62e..596d30104 100644
--- a/runtime/sema/type_tags.go
+++ b/runtime/sema/type_tags.go
@@ -225,12 +225,8 @@ const (
interfaceTypeMask
functionTypeMask
-
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- inclusiveRangeTypeMask
-=======
hashableStructMask
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ inclusiveRangeTypeMask
invalidTypeMask
)
@@ -391,11 +387,8 @@ var (
Or(FunctionTypeTag).
Or(StorageCapabilityControllerTypeTag).
Or(AccountCapabilityControllerTypeTag).
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
+ Or(HashableStructTypeTag).
Or(InclusiveRangeTypeTag)
-=======
- Or(HashableStructTypeTag)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
AnyResourceTypeTag = newTypeTagFromLowerMask(anyResourceTypeMask).
Or(AnyResourceAttachmentTypeTag)
diff --git a/runtime/tests/checker/storable_test.go b/runtime/tests/checker/storable_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/checker/storable_test.go
index c55baebae..58b0f5cfc 100644
--- a/runtime/tests/checker/storable_test.go
+++ b/runtime/tests/checker/storable_test.go
@@ -135,13 +135,8 @@ func TestCheckStorable(t *testing.T) {
},
sema.NeverType,
sema.VoidType,
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
- sema.AuthAccountType,
- sema.PublicAccountType,
- &sema.InclusiveRangeType{MemberType: sema.IntType},
-=======
sema.AccountType,
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+ &sema.InclusiveRangeType{MemberType: sema.IntType},
}
// Capabilities of non-storable types are storable
diff --git a/runtime/tests/checker/typeargument_test.go b/runtime/tests/checker/typeargument_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/checker/typeargument_test.go
index 2a1f16c2b..1c75a29ee 100644
--- a/runtime/tests/checker/typeargument_test.go
+++ b/runtime/tests/checker/typeargument_test.go
@@ -1040,15 +1040,13 @@ func TestCheckTypeArgumentSubtyping(t *testing.T) {
t.Parallel()
- _, err := parseAndCheckWithTestValue(t,
+ checker, err := parseAndCheckWithTestValue(t,
`
let cap: Capability = test
let cap2: Capability<&Int> = cap
`,
&sema.CapabilityType{},
)
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-=======
require.NotNil(t, checker)
capType := RequireGlobalValue(t, checker.Elaboration, "cap")
@@ -1070,7 +1068,6 @@ func TestCheckTypeArgumentSubtyping(t *testing.T) {
},
cap2Type.(*sema.CapabilityType).BorrowType,
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
errs := RequireCheckerErrors(t, err, 1)
assert.IsType(t, &sema.TypeMismatchError{}, errs[0])
@@ -1080,7 +1077,7 @@ func TestCheckTypeArgumentSubtyping(t *testing.T) {
t.Parallel()
- _, err := parseAndCheckWithTestValue(t,
+ checker, err := parseAndCheckWithTestValue(t,
`
let cap: Capability<&String> = test
let cap2: Capability<&Int> = cap
@@ -1092,8 +1089,6 @@ func TestCheckTypeArgumentSubtyping(t *testing.T) {
},
},
)
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-=======
require.NotNil(t, checker)
assert.Equal(t,
@@ -1115,7 +1110,6 @@ func TestCheckTypeArgumentSubtyping(t *testing.T) {
},
RequireGlobalValue(t, checker.Elaboration, "cap2"),
)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
errs := RequireCheckerErrors(t, err, 1)
assert.IsType(t, &sema.TypeMismatchError{}, errs[0])
diff --git a/runtime/tests/interpreter/account_test.go b/runtime/tests/interpreter/account_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/account_test.go
index 321c994b4..3a51b84a2 100644
--- a/runtime/tests/interpreter/account_test.go
+++ b/runtime/tests/interpreter/account_test.go
@@ -444,16 +444,9 @@ func testAccountWithErrorHandler(
accountValueDeclaration.Name = "account"
valueDeclarations = append(valueDeclarations, accountValueDeclaration)
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
valueDeclarations = append(valueDeclarations, stdlib.InclusiveRangeConstructorFunction)
- if checkerConfig.BaseValueActivation == nil {
- checkerConfig.BaseValueActivation = sema.BaseValueActivation
- }
- baseValueActivation := sema.NewVariableActivation(checkerConfig.BaseValueActivation)
-=======
baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation)
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
for _, valueDeclaration := range valueDeclarations {
baseValueActivation.DeclareValue(valueDeclaration)
}
diff --git a/runtime/tests/interpreter/for_test.go b/runtime/tests/interpreter/for_test.go
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/for_test.go
index 5a0ac3581..01fa7fb31 100644
--- a/runtime/tests/interpreter/for_test.go
+++ b/runtime/tests/interpreter/for_test.go
@@ -28,10 +28,7 @@ import (
"github.com/onflow/cadence/runtime/activations"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/sema"
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
"github.com/onflow/cadence/runtime/stdlib"
-=======
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
. "github.com/onflow/cadence/runtime/tests/utils"
"github.com/onflow/cadence/runtime/interpreter"
@@ -373,139 +370,6 @@ func TestInterpretForStatementCapturing(t *testing.T) {
)
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
-type inclusiveRangeForInLoopTest struct {
- start, end, step int8
- loopElements []int
-}
-
-func TestInclusiveRangeForInLoop(t *testing.T) {
- t.Parallel()
-
- baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation)
- baseValueActivation.DeclareValue(stdlib.InclusiveRangeConstructorFunction)
-
- baseActivation := activations.NewActivation(nil, interpreter.BaseActivation)
- interpreter.Declare(baseActivation, stdlib.InclusiveRangeConstructorFunction)
-
- unsignedTestCases := []inclusiveRangeForInLoopTest{
- {
- start: 0,
- end: 10,
- step: 1,
- loopElements: []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
- },
- {
- start: 0,
- end: 10,
- step: 2,
- loopElements: []int{0, 2, 4, 6, 8, 10},
- },
- }
-
- signedTestCases := []inclusiveRangeForInLoopTest{
- {
- start: 10,
- end: -10,
- step: -2,
- loopElements: []int{10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10},
- },
- }
-
- runTestCase := func(t *testing.T, typ sema.Type, testCase inclusiveRangeForInLoopTest) {
- t.Run(typ.String(), func(t *testing.T) {
- t.Parallel()
-
- code := fmt.Sprintf(
- `
- fun test(): [%[1]s] {
- let start : %[1]s = %[2]d
- let end : %[1]s = %[3]d
- let step : %[1]s = %[4]d
- let range: InclusiveRange<%[1]s> = InclusiveRange(start, end, step: step)
-
- var elements : [%[1]s] = []
- for element in range {
- elements.append(element)
- }
- return elements
- }
- `,
- typ.String(),
- testCase.start,
- testCase.end,
- testCase.step,
- )
-
- inter, err := parseCheckAndInterpretWithOptions(t, code,
- ParseCheckAndInterpretOptions{
- CheckerConfig: &sema.Config{
- BaseValueActivation: baseValueActivation,
- },
- Config: &interpreter.Config{
- BaseActivation: baseActivation,
- },
- },
- )
-
- require.NoError(t, err)
- loopElements, err := inter.Invoke("test")
- require.NoError(t, err)
-
- integerStaticType := interpreter.ConvertSemaToStaticType(
- nil,
- typ,
- )
-
- count := 0
- iterator := (loopElements).(*interpreter.ArrayValue).Iterator(inter, interpreter.EmptyLocationRange)
- for {
- elem := iterator.Next(inter, interpreter.EmptyLocationRange)
- if elem == nil {
- break
- }
-
- AssertValuesEqual(
- t,
- inter,
- interpreter.GetSmallIntegerValue(
- int8(testCase.loopElements[count]),
- integerStaticType,
- ),
- elem,
- )
-
- count += 1
- }
-
- assert.Equal(t, len(testCase.loopElements), count)
- })
- }
-
- for _, typ := range sema.AllIntegerTypes {
- // Only test leaf types
- switch typ {
- case sema.IntegerType, sema.SignedIntegerType:
- continue
- }
-
- for _, testCase := range unsignedTestCases {
- runTestCase(t, typ, testCase)
- }
- }
-
- for _, typ := range sema.AllSignedIntegerTypes {
- // Only test leaf types
- switch typ {
- case sema.SignedIntegerType:
- continue
- }
-
- for _, testCase := range signedTestCases {
- runTestCase(t, typ, testCase)
- }
- }
-=======
func TestInterpretEphemeralReferencesInForLoop(t *testing.T) {
t.Parallel()
@@ -873,5 +737,137 @@ func TestInterpretStorageReferencesInForLoop(t *testing.T) {
_, err := inter.Invoke("test")
require.ErrorAs(t, err, &interpreter.DereferenceError{})
})
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
+}
+
+type inclusiveRangeForInLoopTest struct {
+ start, end, step int8
+ loopElements []int
+}
+
+func TestInclusiveRangeForInLoop(t *testing.T) {
+ t.Parallel()
+
+ baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation)
+ baseValueActivation.DeclareValue(stdlib.InclusiveRangeConstructorFunction)
+
+ baseActivation := activations.NewActivation(nil, interpreter.BaseActivation)
+ interpreter.Declare(baseActivation, stdlib.InclusiveRangeConstructorFunction)
+
+ unsignedTestCases := []inclusiveRangeForInLoopTest{
+ {
+ start: 0,
+ end: 10,
+ step: 1,
+ loopElements: []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
+ },
+ {
+ start: 0,
+ end: 10,
+ step: 2,
+ loopElements: []int{0, 2, 4, 6, 8, 10},
+ },
+ }
+
+ signedTestCases := []inclusiveRangeForInLoopTest{
+ {
+ start: 10,
+ end: -10,
+ step: -2,
+ loopElements: []int{10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10},
+ },
+ }
+
+ runTestCase := func(t *testing.T, typ sema.Type, testCase inclusiveRangeForInLoopTest) {
+ t.Run(typ.String(), func(t *testing.T) {
+ t.Parallel()
+
+ code := fmt.Sprintf(
+ `
+ fun test(): [%[1]s] {
+ let start : %[1]s = %[2]d
+ let end : %[1]s = %[3]d
+ let step : %[1]s = %[4]d
+ let range: InclusiveRange<%[1]s> = InclusiveRange(start, end, step: step)
+
+ var elements : [%[1]s] = []
+ for element in range {
+ elements.append(element)
+ }
+ return elements
+ }
+ `,
+ typ.String(),
+ testCase.start,
+ testCase.end,
+ testCase.step,
+ )
+
+ inter, err := parseCheckAndInterpretWithOptions(t, code,
+ ParseCheckAndInterpretOptions{
+ CheckerConfig: &sema.Config{
+ BaseValueActivation: baseValueActivation,
+ },
+ Config: &interpreter.Config{
+ BaseActivation: baseActivation,
+ },
+ },
+ )
+
+ require.NoError(t, err)
+ loopElements, err := inter.Invoke("test")
+ require.NoError(t, err)
+
+ integerStaticType := interpreter.ConvertSemaToStaticType(
+ nil,
+ typ,
+ )
+
+ count := 0
+ iterator := (loopElements).(*interpreter.ArrayValue).Iterator(inter, interpreter.EmptyLocationRange)
+ for {
+ elem := iterator.Next(inter, interpreter.EmptyLocationRange)
+ if elem == nil {
+ break
+ }
+
+ AssertValuesEqual(
+ t,
+ inter,
+ interpreter.GetSmallIntegerValue(
+ int8(testCase.loopElements[count]),
+ integerStaticType,
+ ),
+ elem,
+ )
+
+ count += 1
+ }
+
+ assert.Equal(t, len(testCase.loopElements), count)
+ })
+ }
+
+ for _, typ := range sema.AllIntegerTypes {
+ // Only test leaf types
+ switch typ {
+ case sema.IntegerType, sema.SignedIntegerType:
+ continue
+ }
+
+ for _, testCase := range unsignedTestCases {
+ runTestCase(t, typ, testCase)
+ }
+ }
+
+ for _, typ := range sema.AllSignedIntegerTypes {
+ // Only test leaf types
+ switch typ {
+ case sema.SignedIntegerType:
+ continue
+ }
+
+ for _, testCase := range signedTestCases {
+ runTestCase(t, typ, testCase)
+ }
+ }
}
diff --git a/values.go b/values.go
remerge CONFLICT (content): Merge conflict in values.go
index de6214c05..ad4c90259 100644
--- a/values.go
+++ b/values.go
@@ -2071,7 +2071,7 @@ func (v Contract) GetFieldValues() []Value {
return v.Fields
}
-<<<<<<< 2a2c540f3 (Merge pull request #2915 from darkdrag00nv2/range_type_check_parameterized_type_recursive)
+
// InclusiveRange
type InclusiveRange struct {
@@ -2158,84 +2158,6 @@ func (v *InclusiveRange) String() string {
)
}
-// PathLink
-
-type PathLink struct {
- TargetPath Path
- // TODO: a future version might want to export the whole type
- BorrowType string
-}
-
-var _ Value = PathLink{}
-
-func NewPathLink(targetPath Path, borrowType string) PathLink {
- return PathLink{
- TargetPath: targetPath,
- BorrowType: borrowType,
- }
-}
-
-func NewMeteredPathLink(gauge common.MemoryGauge, targetPath Path, borrowType string) PathLink {
- common.UseMemory(gauge, common.CadencePathLinkValueMemoryUsage)
- return NewPathLink(targetPath, borrowType)
-}
-
-func (PathLink) isValue() {}
-
-func (v PathLink) Type() Type {
- return nil
-}
-
-func (v PathLink) MeteredType(_ common.MemoryGauge) Type {
- return v.Type()
-}
-
-func (v PathLink) ToGoValue() any {
- return nil
-}
-
-func (v PathLink) String() string {
- return format.PathLink(
- v.BorrowType,
- v.TargetPath.String(),
- )
-}
-
-// AccountLink
-
-type AccountLink struct{}
-
-var _ Value = AccountLink{}
-
-func NewAccountLink() AccountLink {
- return AccountLink{}
-}
-
-func NewMeteredAccountLink(gauge common.MemoryGauge) AccountLink {
- common.UseMemory(gauge, common.CadenceAccountLinkValueMemoryUsage)
- return NewAccountLink()
-}
-
-func (AccountLink) isValue() {}
-
-func (v AccountLink) Type() Type {
- return nil
-}
-
-func (v AccountLink) MeteredType(_ common.MemoryGauge) Type {
- return v.Type()
-}
-
-func (v AccountLink) ToGoValue() any {
- return nil
-}
-
-func (v AccountLink) String() string {
- return format.AccountLink
-}
-
-=======
->>>>>>> 32ddd355c (Merge pull request #2993 from onflow/bastian/2992-extend-pragma-expressions)
// Path
type Path struct {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment