Skip to content

Support type instantiation prefixes and methods - #345

Merged
jeparlefrancais merged 6 commits into
mainfrom
type-instantiation
May 15, 2026
Merged

Support type instantiation prefixes and methods#345
jeparlefrancais merged 6 commits into
mainfrom
type-instantiation

Conversation

@jeparlefrancais

@jeparlefrancais jeparlefrancais commented May 15, 2026

Copy link
Copy Markdown
Contributor

This PR add support for type instantiation.

The remove_types rule was also updated to clear this new syntax out.

  • add entry to the changelog

@github-actions

Copy link
Copy Markdown

Coverage after merging type-instantiation into main will be

85.10%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src
   ast_converter.rs88.93%100%91.38%88.81%1051, 1075, 1095–1097, 1118, 1133–1135, 1183, 1187–1190, 1223, 1243, 1258, 1283, 1321, 1340–1342, 1387, 1421, 1436, 1452–1454, 1464, 1469–1471, 1486–1487, 1506, 1653–1655, 1716–1718, 1769–1771, 1795, 1852–1854, 1882–1884, 1900–1902, 1980–1982, 2007–2009, 2016–2018, 2036–2038, 2062–2064, 2134, 2139–2141, 2161, 2167–2169, 2174–2176, 218–220, 2201–2203, 2223, 2280–2282, 2306–2309, 2339–2341, 2346–2348, 235, 2351–2353, 236–237, 2420–2422, 2434–2436, 2445–2447, 2461–2462, 2468–2469, 2483–2484, 2512, 2595–2597, 2625–2627, 2648–2649, 265, 2650, 266–267, 2680–2683, 2698–2699, 2702, 2726–2728, 2740–2742, 2762–2764, 2840–2842, 2874, 3216–3223, 3225–3226, 3228–3229, 3234–3245, 3254, 3256–3258, 3263–3265, 3271, 3297–3299, 3310–3312, 3330–3332, 488–490, 494–496, 513, 547, 608, 624–626, 661–664, 671, 685, 700–702, 706–708, 723–726, 729, 738–740, 781–782, 792–794, 800–802, 845, 870, 965, 969–971, 992
   parser.rs90.63%100%94.12%90.09%24, 32, 609–610, 614, 73–77, 89
src/generator
   dense.rs84.64%100%90.63%84.07%1001–1004, 1010–1017, 1019–1020, 1022, 1024–1032, 1034, 1048, 1057–1061, 1063–1065, 1067–1072, 1075–1078, 1088, 1115–1122, 1148–1154, 1168–1170, 1188–1192, 1200, 1209–1210, 1215, 1221, 1230–1238, 1255, 1277, 1290–1293, 1297–1300, 159–160, 162, 176–177, 179, 250, 290–302, 304–310, 312–313, 324–326, 405, 455, 50–53, 546, 55, 57–59, 61–63, 65, 653–655, 66–68, 689, 69, 710, 760, 780, 80, 963
   mod.rs92.40%100%95%92.17%100–103, 105, 113–118, 429, 445, 449, 95, 97–99
   readable.rs95.23%100%97.25%95.05%1208, 1241–1248, 1250–1251, 1253, 1256, 1258–1266, 1269–1270, 1278–1282, 1307–1311, 1385, 1438–1440, 1507, 1534, 1564, 182, 187–188, 192, 205–206, 211, 216, 234–235, 311, 455, 48, 50–53, 55
   token_based.rs89.61%100%90.91%89.48%1011, 1057–1059, 1130–1131, 1140–1141, 1148, 1163, 1168–1172, 1191–1192, 1205–1206, 1227–1228, 1242–1244, 1267–1268, 1277–1279, 1298–1299, 1308–1310, 1361–1366, 139–140, 1520, 156–157, 1617, 1634–1641, 1643, 1666–1674, 169–170, 1715–1726, 1798–1800, 1832–1841, 1886–1892, 1894–1896, 191–192, 1920, 1978, 212–214, 2356–2362, 2364–2374, 2376–2378, 2380, 2384, 240–241, 2433–2437, 2493–2494, 2553–2557, 280, 2812, 2816, 2829, 332–336, 406–407, 413, 425, 451, 488–489, 496–497, 499–506, 509–510, 512–520, 531–538, 594–595, 617–618, 634–635, 677, 766–767, 800–801, 835–836, 89, 898–899, 941–942, 990–994
   utils.rs91.64%100%93.94%91.40%140, 33–35, 355, 369, 37, 370, 39, 404–408, 445–453, 63, 73, 83
src/nodes
   function_call.rs91.28%100%90.32%91.49%145–149, 191, 220–222, 237–238
src/nodes/expressions
   binary.rs93.29%100%96.55%92.98%100, 317, 326–328, 75–76, 85–87, 89–91, 95–99
   mod.rs82.72%100%97.44%79.90%111–121, 123–129, 131–133, 140–144, 146–150, 152–156, 227–229, 416
   prefix.rs53.57%100%69.23%50.70%119–121, 137–139, 155–157, 38–40, 44–46, 50–51, 53–55, 62–70, 73, 80, 82–85
   type_instantiation.rs59.02%100%66.67%57.14%100–105, 107–109, 48–51, 90–92, 96–99
src/process
   node_processor.rs95.37%100%95.28%95.45%30–31, 72, 95–96
   post_visitor.rs88.56%100%96.92%87.70%180–182, 185, 189, 237–239, 242, 246, 264–266, 296–298, 312–314, 317, 321, 349, 356, 544–548, 550–553, 556–565, 569–574, 578–580, 587–588, 590–597, 601–602, 604–605, 607–616, 619, 622–623
   visitors.rs93.25%100%97.33%92.79%507–510, 512–515, 518–527, 531–536, 547–548, 550–557, 560, 562–563, 565–574, 577, 579
src/process/evaluator
   mod.rs82.51%100%93.10%81.07%100–101, 104, 109–110, 186, 198, 204–205, 212, 223, 232–234, 242, 244–246, 248–249, 252, 264–266, 278–282, 286–287, 289–291, 293–294, 299–304, 341, 362, 376, 400, 403, 436, 442–443, 448, 462, 483, 54–56, 67–69, 79–82, 85–86, 874, 94–95, 97, 99
src/rules
   remove_comments.rs89.85%100%88.02%90.45%100, 102, 104–106, 325, 365–372, 376, 378, 380–382, 392, 478, 556–557, 89–96
   remove_compound_assign.rs95.69%100%92.31%96.12%282–284, 345–347, 59, 88
   remove_method_call.rs92.96%100%90.91%93.33%100–101, 39, 99
   remove_spaces.rs92.61%100%95%91.96%100, 102, 104–106, 283, 294–296, 89–96
   remove_types.rs96.23%100%95%96.51%118–120
   replace_referenced_tokens.rs90.03%100%92.06%

Comment on lines +13 to +14
assign_field_expression_and_nil("local a, b = object.prop, nil") => "local a, b = object.prop",
assign_index_expression_and_nil("local a, b = object[key], nil") => "local a, b = object[key]",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After doing some tests, I found out that custom __index metamethod returning multiple values will get cut to a single value, so no need to add parentheses anymore 👍

@jeparlefrancais
jeparlefrancais merged commit 412722e into main May 15, 2026
6 checks passed
@jeparlefrancais
jeparlefrancais deleted the type-instantiation branch May 15, 2026 18:55
@jeparlefrancais jeparlefrancais mentioned this pull request Jun 10, 2026
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.

1 participant