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

feat: allow using the throwaway ('_') var #128

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

Conversation

daniel-makerx
Copy link
Contributor

No description provided.

@daniel-makerx daniel-makerx force-pushed the allow-throwaway_var branch 2 times, most recently from 5feb20a to 64efd81 Compare March 13, 2024 13:21
Copy link

github-actions bot commented Mar 13, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/puya
   __main__.py31197%116
   arc4_util.py104892%30, 78–79, 93, 105, 107, 143, 162
   arc32.py125398%109, 120, 223
   client_gen.py1071070%1–195
   compile.py183796%143, 157–160, 177–178, 249–250
   errors.py1222976%47–48, 52, 54–57, 82, 124, 144–145, 150–164, 175–178
   logging_config.py1292878%15, 36–39, 45, 47, 50–54, 69, 88, 141–143, 146–148, 150, 163–172, 194
   models.py101397%10–13
   options.py30293%12–13
   parse.py2031792%85, 97, 126, 168, 222, 265, 275, 277, 281, 309–314, 318, 348, 362, 374–375
   utils.py1642386%51, 55, 89, 95, 110, 113–115, 122, 144, 157–158, 162, 166–169, 198, 200, 223, 235, 240, 245, 256
src/puya/awst
   function_traverser.py190398%116, 146–147
   nodes.py9276993%18–27, 43, 52, 86, 92, 96–99, 133, 139, 143–146, 280, 524, 727–728, 748, 760, 798, 804–805, 835, 861, 865–869, 881, 937, 979–980, 985, 1000, 1051, 1056, 1114, 1139, 1156, 1304, 1352, 1357–1358, 1365–1370, 1412, 1495, 1543, 1552, 1580, 1587, 1600, 1642, 1684, 1695, 1697, 1702, 1710, 1715, 1720, 1729, 1734, 1739, 1746
   to_code_visitor.py3251396%83–84, 87–90, 114–115, 196, 331–332, 426–427, 498, 526
   visitors.py2237367%7, 15, 19, 23, 27, 31, 35, 39, 43, 47, 53, 59, 65, 69, 73, 77, 83, 87, 91, 95, 99, 103, 109, 113, 117, 121, 125, 129, 133, 137, 141, 147, 151, 155, 161, 167, 171, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 239, 242, 245, 251, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321
   wtypes.py3063489%21, 190–201, 216–219, 236, 238, 283, 286, 311, 314, 316, 319, 344, 363, 399, 402, 451–452, 461–462, 470–471, 482, 485, 544, 556, 572
src/puya/awst_build
   arc4_utils.py1513676%50, 52, 55, 67, 94–95, 110, 114, 117, 123, 126, 129, 132, 140, 148, 151, 154–166, 169, 178, 181, 264, 336, 343, 346
   base_mypy_visitor.py1334467%39, 59, 71–77, 95, 106–121, 135, 139, 143, 154, 158, 166, 172, 178, 196, 202, 207, 210, 213, 222, 226, 231, 236, 242, 247, 253, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308
   context.py1472285%59–60, 136–141, 149, 151–155, 158–159, 179, 184, 188, 201, 213–214
   contract.py2235974%130–131, 133–136, 144–145, 148, 160, 171, 193, 211, 217, 219, 228, 238, 247, 275, 279, 295–299, 307–308, 313, 316, 319, 322, 327–328, 331, 339, 342, 345, 348, 351, 354, 357, 360, 363, 366, 380, 394–401, 410–417, 424–425, 448, 458–459, 466, 472, 494–500
   intrinsic_factory.py31294%10, 83
   intrinsic_models.py32584%21, 26–29
   main.py48394%32, 49, 59
   module.py4028080%75, 143, 157–159, 177–178, 185, 193, 199, 205–209, 214, 226, 250–251, 262, 292, 318–319, 342, 349, 371–372, 395–400, 454–455, 466, 483, 494, 497, 503, 511, 514, 521, 527, 539, 542, 564, 585, 591, 600–601, 619–654, 678, 686–687, 701–703, 705, 707–708, 733, 741, 743
   subroutine.py6287588%219, 230, 290, 296, 364, 368, 382, 390, 424–425, 565–580, 588, 596, 599, 611, 643–644, 649, 654, 691, 711–712, 735–741, 794–795, 800, 816, 819, 822, 830–836, 890, 894–895, 899–900, 916, 918, 921–923, 948–949, 957, 992–1000, 1035, 1063, 1067, 1098, 1174, 1202, 1209, 1219, 1230–1234, 1243, 1246, 1249, 1252, 1255, 1260, 1265, 1272, 1279
   utils.py1651790%41, 78, 93, 96–97, 101, 143, 146–147, 166, 180, 193, 200, 238, 259, 312–313
src/puya/awst_build/eb
   _utils.py21290%14–15
   app_account_state.py1282878%51–54, 62, 78, 80, 112–113, 134–141, 162–163, 168, 175–176, 178, 195–196, 203–204, 233, 238–239
   app_state.py1232679%35–40, 51–58, 79–80, 85, 95–96, 101, 118–119, 126–127, 168–169, 192, 210
   array.py684534%26–27, 30–32, 37–44, 56–72, 77–79, 82, 85–88, 93–95, 100–102, 111–123
   base.py2086171%25–32, 104, 108, 112, 118, 122, 128–133, 144–150, 155–161, 167, 173, 183, 193, 197, 201, 211, 214, 217, 220, 223, 226, 231, 234, 256, 277, 280, 285, 288, 291, 294, 297, 302, 305, 316, 329, 339, 342, 355, 376, 381, 390, 393, 397, 404, 407, 410, 415, 420, 425, 431
   biguint.py902276%34–38, 62–63, 77, 92, 102–105, 127–130, 147–152, 169–177, 180–181
   bool.py40880%27–31, 49–50, 53–54, 72
   bytes.py1411987%55–59, 81–82, 93–94, 114–115, 119, 123, 128, 130–131, 151, 173, 287–288, 317
   bytes_backed.py29486%37–38, 47–48
   contracts.py44295%57, 61
   ensure_budget.py481569%25–29, 49–50, 70–71, 79, 91, 97–102
   intrinsics.py1564372%32–34, 55–56, 64–65, 71–72, 89–90, 97, 126, 135, 137–161, 168–169, 213, 221, 233–234, 236, 253–254, 266, 271, 278, 281
   log.py52983%25–29, 79–85, 95, 97
   named_int_constants.py20290%23–24
   string.py1191587%42–46, 67–68, 86–87, 100–101, 128–129, 181, 239–240, 255
   struct.py321553%21–22, 25, 35–41, 46–48, 51–56
   subroutine.py51590%48, 63, 89, 92, 107
   template_variables.py471079%25–26, 59–60, 64, 69, 72–73, 82–83
   throwaway.py461372%21–25, 35, 38, 47, 50, 53, 59, 62, 65, 70
   tuple.py982080%39–40, 47, 58, 60–61, 83–84, 93–94, 107, 113, 131–132, 137–138, 150, 158, 166, 198
   type_registry.py31487%152–153, 164–165
   uint64.py791581%37–41, 62–63, 84, 102, 125, 144–147, 161–169, 172–173
   unsigned_builtins.py701184%30–34, 51, 58, 92, 95–96, 126, 129–130
   value_proxy.py391269%24, 27, 30, 33, 36, 41, 56, 66, 75, 84, 87, 90
src/puya/awst_build/eb/arc4
   utils.py1602187%25–28, 60–61, 63, 66–67, 89–90, 120, 125–126, 165, 200, 206, 211–213, 257, 262
   abi_call.py1672386%51–54, 109, 118–119, 137–138, 142–143, 182, 194, 212–213, 275–281, 310–311, 372, 375, 377
   arrays.py2252987%63–67, 80–81, 108, 138, 158–159, 194, 196, 229, 256, 272–273, 286, 329–330, 383–384, 406, 416–417, 433, 462, 481–482, 490, 536
   base.py1042378%36–40, 68–69, 74–75, 84–92, 147–148, 168, 177–178, 195–196, 206, 216, 221
   bool.py31681%19–26, 47–48
   dynamic_bytes.py42588%15–19, 60–61
   emit.py33779%26–30, 55–56, 64–65
   numeric.py1141785%30–34, 46, 60, 74, 81–82, 105, 132–133, 139, 145, 198–201
   string.py661282%33–37, 54, 57, 86, 105–106, 131–132, 150–151
   struct.py58886%26–33, 68, 71, 106–107
   tuple.py831780%29–33, 48, 52–53, 82, 91, 102, 111, 124, 128–129, 156–157, 166–167
src/puya/awst_build/eb/reference_types
   account.py621084%30–34, 51, 60–64, 105
   application.py32778%15–19, 35–36, 40–41
   asset.py52983%26–30, 46–47, 51–52, 88–89
   base.py44491%25–27, 61, 87
src/puya/awst_build/eb/transaction
   base.py35877%17–18, 26, 30, 35–36, 43, 52
   group.py571574%33–37, 87–88, 141–154
   inner.py56886%27–32, 64–65, 115, 142
   inner_params.py1041189%31–35, 43–44, 54, 110, 145, 169, 185, 217
src/puya/awst_build/validation
   arc4_copy.py43198%38
   base_invoker.py31584%33, 40, 49–54
   inner_transactions.py94298%111, 125
   scratch_slots.py38489%17, 31, 47, 49
src/puya/ir
   arc4_router.py2462092%131, 149, 157, 307, 381, 427, 491–492, 506, 546–547, 559, 564, 569, 574, 579, 584, 604–609
   avm_ops.py316299%46–47
   avm_ops_models.py48394%21, 30, 38
   context.py911287%18, 71–72, 74, 92–98, 103, 114, 121, 131
   main.py222697%139, 142, 308, 310, 415, 426
   models.py4702694%29, 45, 63, 79, 186, 196, 200, 374, 448, 490, 570, 586, 627, 630, 637, 640, 696, 705, 713, 719, 730–732, 742, 754, 791
   ssa.py136993%43, 51–52, 99, 105, 141, 145, 166, 170
   to_text_visitor.py143994%86, 91, 175–176, 182–187
   types.py50786%27–28, 58–61, 72
   visitor.py1713778%10–12, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 174, 186, 201, 204, 207, 213, 216, 222, 225, 228, 231, 234, 237, 240, 243
   visitor_mutator.py93298%138–139
   vla.py73297%50, 87
src/puya/ir/builder
   _utils.py71889%33, 44, 57, 79–80, 157, 203–204
   arc4.py4224889%76–77, 126, 150–156, 220, 228, 451, 463, 466, 622–636, 965–979, 1005–1029, 1038–1054, 1077, 1184–1185, 1230–1247, 1286–1287, 1340, 1373–1374, 1522–1523, 1586
   assignment.py43588%59, 75, 102, 133–134
   blocks.py931089%62, 72, 76, 112, 120, 124, 157–159, 165–167
   callsub.py57198%93
   flow_control.py98496%63, 117, 141, 155
   iteration.py190597%46, 66, 95, 176–177
   itxn.py2692690%123–124, 139–140, 150–151, 157–162, 188, 468–469, 474–475, 480–481, 487, 498, 515–516, 558–561
   main.py4765189%94, 119, 145, 154, 158, 203–204, 220–221, 255, 263, 270–271, 342, 380, 392, 409, 430, 437, 471, 484, 522, 535–536, 600–601, 623, 671, 699, 717, 752–753, 828, 831, 837, 844–845, 875–876, 891, 937–938, 954–955, 989, 1004–1006, 1015, 1018–1019
src/puya/ir/destructure
   coalesce_locals.py941584%33, 36, 118, 127–128, 131–134, 137–139, 155–158
   parcopy.py84298%47, 83
src/puya/ir/optimize
   _utils.py28196%21
   collapse_blocks.py92595%65–69
   control_op_simplification.py1011189%158–165, 239–246
   dead_code_elimination.py118298%289, 325
   intrinsic_simplification.py3703989%64, 128, 140, 202, 271, 329, 335, 386, 408, 429, 431, 437, 481, 483, 485, 492, 522, 528, 530, 532, 537, 539, 541, 543, 545, 548–551, 558, 560, 562, 564, 566, 568, 572, 595–596, 603
   main.py85396%106–107, 123
src/puya/ir/validation
   min_avm_version_validator.py29390%25–26, 39
   op_run_mode_validator.py41880%23–24, 45–56
src/puya/mir
   annotaters.py172796%56, 62, 98, 102, 135, 139, 216
   builder.py120596%90, 138, 144, 251–252
   context.py39197%35
   models.py3352493%14–18, 30, 41, 53, 69–70, 78, 89, 100, 111, 141, 251, 282, 319, 331, 348, 356–362, 368
   output.py61297%29, 31
   stack.py2532291%68, 72, 115, 119, 125, 135, 146, 157, 167, 182, 199, 209, 228, 246, 252, 254, 293, 304, 328, 360, 365, 403
   visitor.py762468%7, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103
src/puya/mir/stack_allocation
   baileys.py208697%31, 103, 123, 330–334, 359
   frame_allocation.py80396%21, 64–65
   koopmans.py61198%55
   peephole.py100694%75, 89, 99, 101, 103, 145
src/puya/teal
   models.py229299%292, 298
src/puya/teal/optimize
   peephole.py112496%154–164, 172
   repeated_rotations.py30197%13
   repeated_rotations_search.py88693%34, 40–41, 57, 67–68
TOTAL16507191788% 

Tests Skipped Failures Errors Time
268 2 💤 0 ❌ 0 🔥 2m 47s ⏱️

msg="Python literals (other than True/False) are not valid as tuple elements",
).rvalue()
for mypy_item in mypy_expr.items
eb.lvalue() if self._is_lvalue_context else eb.rvalue()
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty sure this will allow referencing a _ variable if inside, say, a function call that occurs on the LHS of an assignment, or any other situation where an rvalue context is entered from within an lvalue one

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.

3 participants