Commit d41b5b2
committed
feat: add type annotation support for function parameters
- Update fn_param grammar rule to support optional type annotations (name: Type)
- Add alloc_handle and store_type methods to AstHostFunctions trait
- Default to Type::Any for parameters without type annotations (for dynamic typing)
- Type inference will resolve actual types based on use-case before Cranelift
This enables both dynamic typing (fn add(x, y)) and static typing (fn add(x: Int, y: Int))
in the same grammar, supporting gradual typing in ZynML.1 parent 956b692 commit d41b5b2
2 files changed
Lines changed: 72 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
371 | 377 | | |
372 | 378 | | |
373 | 379 | | |
| |||
1127 | 1133 | | |
1128 | 1134 | | |
1129 | 1135 | | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | 1136 | | |
1138 | 1137 | | |
1139 | 1138 | | |
| |||
1293 | 1292 | | |
1294 | 1293 | | |
1295 | 1294 | | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
1296 | 1305 | | |
1297 | 1306 | | |
1298 | 1307 | | |
| |||
4025 | 4034 | | |
4026 | 4035 | | |
4027 | 4036 | | |
| 4037 | + | |
4028 | 4038 | | |
4029 | 4039 | | |
4030 | | - | |
| 4040 | + | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
| 4044 | + | |
| 4045 | + | |
4031 | 4046 | | |
4032 | 4047 | | |
4033 | 4048 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
| 433 | + | |
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
450 | 454 | | |
451 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
452 | 489 | | |
453 | 490 | | |
454 | 491 | | |
| |||
580 | 617 | | |
581 | 618 | | |
582 | 619 | | |
583 | | - | |
584 | | - | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
585 | 623 | | |
586 | | - | |
587 | | - | |
588 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
589 | 630 | | |
590 | 631 | | |
591 | 632 | | |
| |||
0 commit comments