Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow staticarrays to be constructed with no arguments #281

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tristanmenzel
Copy link
Contributor

DynamicArray[AddressArray]()
)
# TODO: The following should either work, or fail gracefully
# x = StaticArray[TestStruct, typing.Literal[4]]()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume it's possible to add a default ctor to the arc4.Structs but it maybe doesn't make much sense. Is it better to just error when attempting to construct a static array of struct without any values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't jive with the datalcass vibe - not unless the class had default values for all fields (which we don't support yet)

Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/puya
   __main__.py35197%145
   arc4_util.py48296%61, 63
   arc32.py68297%77, 103
   artifact_sorter.py49198%80
   client_gen.py1151587%55–56, 65–69, 73, 165–166, 174–175, 190, 194–195, 204
   compile.py2532291%193–194, 240–241, 263, 273, 285–286, 297, 304–305, 322–332, 342–344, 349, 478, 499
   context.py37197%44
   errors.py451567%43–53, 66–67, 69–71
   log.py2122986%36–39, 72, 92, 126–127, 169–171, 174–176, 178, 191–200, 222, 292–294, 303–304, 338, 355
   models.py132298%118, 131
   parse.py2221195%96, 108, 133, 227, 318–323, 327, 425–426, 429
   template.py44686%18–19, 41–42, 58, 60
   utils.py2212688%55, 72–73, 82–83, 91–92, 149, 153, 187, 193, 208, 211–213, 220, 242, 255–256, 264–267, 296, 298, 321, 356
src/puya/awst
   function_traverser.py207399%53, 296, 301
   nodes.py9525394%88, 92–95, 135, 139–142, 308, 485, 501, 519, 566, 593–594, 650, 654, 682–683, 789, 825, 847, 879, 901, 906, 911, 1115, 1131, 1180, 1233–1234, 1241–1246, 1288, 1368, 1421, 1425, 1475, 1488, 1533, 1627, 1638, 1640, 1645, 1653, 1658, 1663, 1672, 1677, 1682, 1689
   to_code_visitor.py347898%123, 307–308, 350, 555, 576, 606, 609
   txn_fields.py98199%48
   wtypes.py2371992%155–159, 169–172, 187, 202, 230, 266, 290, 295, 336, 364, 366, 466
src/puya/awst_build
   arc4_utils.py3164984%43, 46–47, 49, 81, 93–95, 119, 130–134, 150, 152, 155–156, 179, 217–219, 228, 233, 238–239, 263, 267, 279, 286, 288, 302–303, 306–310, 315–316, 322–325, 333, 351, 363, 371–372, 384, 392, 493, 498, 517
   arc32_client_gen.py68297%35, 131
   base_mypy_visitor.py1273969%70–76, 94, 102–115, 129, 131, 133, 145, 150, 154, 157, 160, 166, 188, 191, 194, 201, 205, 208, 211, 215, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281
   context.py2274779%49, 71, 74, 84–85, 111–112, 208, 213, 219–223, 228, 237, 239, 242–244, 246, 253, 255, 261, 266–267, 272–274, 277, 297, 321–322, 334, 348, 351–363
   contract.py1953184%125–126, 128–131, 143, 155, 248, 252, 267–271, 279, 288, 291, 303, 311, 314, 317, 320, 323, 326, 329, 332, 335, 346, 356, 364, 370, 395–401
   contract_data.py58198%37
   intrinsic_models.py40198%49
   main.py48394%33, 50, 60
   module.py4156285%53–56, 85, 150, 164–166, 181–182, 189, 198–199, 207–211, 229–233, 240, 264–265, 276, 298–301, 311–313, 319, 342–345, 358, 392, 399, 421–422, 445–450, 504–505, 533, 544, 547, 553, 559, 569, 575, 578, 590, 593, 615, 635, 640, 644, 648–651, 678, 736, 744, 746
   pytypes.py4725189%85–87, 101–102, 142, 158–164, 187, 207, 279, 288, 307, 311, 327–328, 360, 453–455, 469–470, 539–540, 665, 676–677, 725–726, 731, 780–781, 802–803, 932–933, 957, 985, 1019–1021, 1047, 1074, 1084–1085, 1121–1123
   subroutine.py6195192%138, 260, 266, 324–327, 333, 385, 392, 395–401, 466, 581, 583–584, 602, 604, 614–615, 624–625, 629, 650, 728, 735, 755–756, 838, 869–870, 887, 909, 915, 1003, 1011, 1022, 1047, 1153–1154, 1175, 1185, 1192, 1205, 1230, 1233, 1236, 1239, 1242, 1262–1264
   utils.py1952587%36, 53–57, 73, 108–109, 111, 155–156, 228, 236, 241, 254–258, 263–266, 274, 301, 309, 352
src/puya/awst_build/eb
   _base.py1281985%53, 58–60, 65, 72, 77, 82–84, 143, 154, 178, 183, 188, 193, 204, 219, 224–226
   _bytes_backed.py48296%30–31
   _expect.py1251886%25, 36, 77–80, 92–95, 98, 157–158, 219, 232–235
   _literals.py1382979%42, 71, 90, 119, 127, 141, 145, 149–155, 165–179, 184
   utils.py44198%95
   array.py27967%24, 29–34, 44, 50
   biguint.py97694%57, 99, 136, 151–152, 154
   bool.py51884%38–42, 58, 69, 84
   bytes.py1711889%105–106, 133–134, 139–140, 146–147, 150, 158, 201, 236, 269, 273, 290–291, 306–307
   compiled.py1141389%57, 62, 68–69, 172–178, 213–217, 242
   conditional_literal.py1263572%93, 97, 151, 155–158, 167–169, 178–181, 192–195, 204, 208, 212–215, 230–242, 251–252
   contracts.py84693%64, 70, 83, 108, 129, 133
   dict.py27581%24, 32–34, 38
   ensure_budget.py33197%49
   interface.py85396%304–306, 310
   intrinsics.py97694%38, 57, 64, 77, 84, 155
   log.py43491%46–47, 52, 61
   logicsig.py15193%26
   none.py25388%17, 28, 37
   string.py1451391%72, 115–116, 135, 139, 183, 190, 194, 206, 280–282, 302
   struct.py17571%15–17, 26, 32
   subroutine.py791778%50, 54–57, 72, 75–82, 97, 105–109, 111–114, 119
   template_variables.py37295%30, 58
   tuple.py2691296%75, 147, 153, 188–189, 195, 272–273, 398, 409–410, 473
   uint64.py114596%59, 123–124, 172–173
   uint64_enums.py40295%41, 46
   unsigned_builtins.py1532186%75, 82, 106, 130, 134, 138, 142, 150, 154, 158, 162, 166, 176, 180, 186, 197, 203, 242, 274, 286, 298
src/puya/awst_build/eb/arc4
   _base.py91397%187–190, 201
   _utils.py113992%61–62, 87, 92, 122–125, 165, 169, 183
   abi_call.py3331895%122, 128, 131, 153, 223, 244–245, 326, 345, 406, 458, 476, 506, 592, 641, 726–727, 744
   address.py77396%57, 117–118
   bool.py57395%44, 86–87
   dynamic_array.py1271092%57, 126–127, 147, 149, 154, 228, 249, 255–258
   dynamic_bytes.py68396%97–99
   emit.py37197%39
   static_array.py68199%41
   string.py100991%54–55, 103, 126, 131–134, 161–162
   struct.py49198%49
   tuple.py941584%50–52, 92–95, 98–99, 135–138, 143, 147–148, 158, 168
   ufixed.py70297%43, 102
   uint.py75495%81–83, 135–136
src/puya/awst_build/eb/reference_types
   _base.py52198%119
   account.py81298%60, 171
   application.py45198%35
   asset.py65198%43
src/puya/awst_build/eb/storage
   _common.py69396%104, 119–120
   _storage.py1001783%77, 85, 89, 93, 97, 101, 105, 109, 113, 123, 127, 131, 135, 141, 152, 158, 170
   value_proxy.py55787%39, 43, 51, 55, 92, 100, 104
   box_map.py143199%183
   global_state.py139596%108–109, 115, 171–172
   local_state.py1491193%103–104, 108, 157, 161, 165, 175, 179, 203, 290, 314
src/puya/awst_build/eb/transaction
   base.py39295%23, 43
   inner.py48296%88–89
   inner_params.py81594%69, 79, 83, 143, 145
   itxn_args.py60198%68
src/puya/awst_build/validation
   base_invoker.py29486%31, 38, 47–51
   inner_transactions.py181199%160
   scratch_slots.py39490%19, 33, 49, 51
src/puya/ir
   arc4_router.py3272194%157, 175, 183, 251, 341, 520–521, 535, 579–580, 592, 597, 602, 607, 612, 617, 637–641, 876, 909–910
   avm_ops.py315199%46
   avm_ops_models.py48394%21, 30, 38
   context.py87792%73, 95–101, 106, 129, 137
   main.py250299%466, 484
   models.py5352296%74, 183, 190, 345, 415–416, 421, 427–431, 444, 488, 515, 570, 612, 692, 708, 749, 752, 759, 762, 852–853
   ssa.py130298%51–52
   to_text_visitor.py152895%123, 128, 212, 219–224
   types.py94990%49, 56, 90–94, 103, 140–142
   visitor.py1291787%145, 193, 205, 220, 223, 236, 239, 245, 248, 259, 262, 265, 268, 271, 274, 277, 280
   visitor_mutator.py105298%174–175
   vla.py72199%87
src/puya/ir/builder
   _utils.py76593%78, 204, 240–242
   arc4.py5012795%91, 127–132, 386, 389, 458–461, 725–726, 972, 996, 1085–1102, 1123–1140, 1179–1180, 1232, 1242, 1297, 1342, 1361, 1381, 1445–1452
   assignment.py72593%49, 84, 168, 186, 202
   blocks.py90298%162, 170
   bytes.py641478%23–55, 139
   callsub.py57198%93
   flow_control.py96199%72
   iteration.py175498%44, 66, 92, 165
   itxn.py2661395%125–126, 128, 141, 189, 209, 234–235, 563, 587–588, 601–602
   main.py5285789%103, 235, 239, 244–262, 267–285, 340, 364, 388–389, 423, 585, 607–610, 626–627, 667, 693, 737–739, 750, 815, 933, 946, 979, 1034, 1037, 1045, 1048, 1056, 1087, 1149, 1166, 1216–1217
   storage.py82298%99, 151
src/puya/ir/destructure
   coalesce_locals.py1011981%119, 128–129, 132–135, 138–147, 163–166
   parcopy.py84298%47, 83
src/puya/ir/optimize
   collapse_blocks.py92595%65–69
   compiled_reference.py79594%53, 87, 158–163
   control_op_simplification.py1011090%159–166, 240–247
   inner_txn.py36197%38
   intrinsic_simplification.py4602994%76, 166–168, 173, 255, 267, 316–317, 337, 404, 542, 570, 591, 593, 608, 663, 693, 699, 701, 703, 708, 710, 712, 714, 716, 768–769, 776
   main.py87397%114–115, 131
src/puya/ir/validation
   _base.py29197%24
   compile_reference_validator.py20385%24, 30, 37
   min_avm_version_validator.py11191%15
   op_run_mode_validator.py19574%19–29
src/puya/mir
   annotaters.py159299%62, 212
   builder.py1401093%139, 248–249, 302, 305, 308, 311, 314, 317, 320
   context.py39197%35
   models.py3281695%40, 52, 68, 77, 88, 99, 110, 150, 260, 291, 328, 340, 365–371
   output.py61297%29, 31
   stack.py2501992%72, 119, 135, 146, 157, 167, 184, 201, 211, 230, 250, 256, 258, 297, 310, 334, 366, 371, 409
src/puya/mir/stack_allocation
   baileys.py205399%31, 330–334
   frame_allocation.py80298%21, 68
   koopmans.py61198%55
   peephole.py100694%75, 89, 99, 101, 103, 145
src/puya/teal/optimize
   peephole.py112397%139, 145, 169
   repeated_rotations.py42198%13
   repeated_rotations_search.py88693%34, 40–41, 57, 67–68
src/puya/ussemble
   build.py731086%37, 52–53, 58–61, 65–68, 85–86, 115
   op_spec_models.py22195%20
   optimize.py77199%78
   output.py115199%71
   validate.py17194%19
TOTAL20435138993% 

Tests Skipped Failures Errors Time
939 3 💤 0 ❌ 0 🔥 6m 16s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants