Commit 1cc55cc
committed
feat: auto-inject extern function declarations for @Builtin mappings
Fixes the "cannot find value in this scope" type checking error by automatically
creating TypedDeclaration::Function entries (with is_external=true) for all functions
declared in the @Builtin directive.
Implementation:
- Added inject_builtin_externs() method to LanguageGrammar
- Called after parsing in parse_with_filename() to inject externs into TypedProgram
- Creates extern function declarations with proper return types from @types
- Uses empty parameter list for now (parameter signatures need enhancement)
Results:
- Type checker now finds builtin functions like println, tensor, etc. in scope
- Eliminates "cannot find value in this scope" errors for extern builtins
- All 98 builtins from ml.zyn are now properly declared in the AST
Known limitations:
- Parameter signatures not yet specified (type checker warns about arg count)
- Proper varargs/Rest parameter support needs compiler implementation
- Next step: extend @Builtin directive to include parameter type information1 parent ac7d76d commit 1cc55cc
1 file changed
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
278 | 282 | | |
279 | 283 | | |
280 | 284 | | |
| |||
341 | 345 | | |
342 | 346 | | |
343 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
344 | 406 | | |
345 | 407 | | |
346 | 408 | | |
| |||
0 commit comments