Resolve FFI externals in the type checker, not the parsetree
๐ Internalfrontendtypecheckersyntaxgentypetests
pval_prim is the primitive string as written, with its location. The frontend still checks each FFI external, but Typedecl gets its spec through Primitive.resolve_external, so the parsetree no longer depends on External_ffi_types.
๐ InternalKeep resolved FFI specifications out of the parsetree, which now holds an external's primitive string as written. #8728
Review
- Why does the frontend resolve each external at all? It reports the errors and warnings where they were reported before, and decides whether a relative
@modulekeeps other modules from inlining the external. The type checker's second resolution runs without warnings. - How do
@inlineconstants work withoutPrim_inline_const? The built-in PPX turns them into an external with the internal primitive#rescript-inlinethat keeps the@inline(<literal>)attribute. - Is the global
Primitive.resolve_externalsafe with parallel requests?Ast_externalsets it once during module initialization, like theOprinthooks, and it is only read afterwards.
- No effect
- Formatting: unchangedEditor: unchanged
- Output
- unchangedgenerated JS of the test suites is byte-identical
- Formats
- astcmt
- PPX
- unchangedan external's primitive string reaches v0 as before
- Errors
- none, the new fixture follows the warning_<NN> naming convention
- Tests
- syntax
tests/syntax_tests/data/+ ast-mapping/Externals.ressuper_errorstests/build_tests/+ super_errors/fixtures/warning_101_external_arg_attribute.resounittests/ounit_tests/~ ounit_ast_mapper0_tests.ml~ ounit_string_literal_tests.ml
- Changelog fragment changes/resolve-ffi-externals.internal.md
- No committed generated JS changes
- Magic numbers bumped: ast_impl ResImpl01317, ast_intf ResIntf01317, cmt Caml1999T045
- v0 PPX bridge changes; ast-mapping fixture or mapper unit test in the diff
- 1 new super_errors fixture; ERROR_VARIANTS.md unchanged, as the Errors trailer states
43 files ยท +480 โ402 ยท changelog 1 ยท lambda 1 ยท compiler 1 ยท frontend 13 ยท gentype 1 ยท typechecker 17 ยท syntax 3 ยท tests 6
| A | changes/resolve-ffi-externals.internal.md | +1 | โ0 |
| M | compiler/core/lam_compile_external_call.ml | +1 | โ1 |
| M | compiler/ext/config.ml | +3 | โ3 |
| M | compiler/frontend/ast_attributes.ml | +4 | โ5 |
| M | compiler/frontend/ast_attributes.mli | +1 | โ1 |
| M | compiler/frontend/ast_exp_handle_external.ml | +4 | โ7 |
| M | compiler/frontend/ast_external.ml | +93 | โ65 |
| M | compiler/frontend/ast_external.mli | +10 | โ0 |
| M | compiler/frontend/ast_external_mk.ml | +40 | โ17 |
| M | compiler/frontend/ast_external_mk.mli | +19 | โ7 |
| M | compiler/frontend/ast_external_process.ml | +24 | โ29 |
| M | compiler/frontend/ast_external_process.mli | +12 | โ13 |
| M | compiler/frontend/bs_ast_invariant.ml | +21 | โ25 |
| M | compiler/frontend/bs_ast_invariant.mli | +15 | โ2 |
| M | compiler/frontend/bs_builtin_ppx.ml | +38 | โ132 |
| M | compiler/frontend/ppx_entry.ml | +4 | โ2 |
| M | compiler/gentype/translation.ml | +2 | โ3 |
| M | compiler/ml/ast_helper.mli | +1 | โ1 |
| M | compiler/ml/ast_iterator.ml | +2 | โ3 |
| M | compiler/ml/ast_mapper.ml | +1 | โ1 |
| M | compiler/ml/ast_mapper_from0.ml | +3 | โ1 |
| M | compiler/ml/ast_mapper_to0.ml | +1 | โ8 |
| M | compiler/ml/external_ffi_types.ml | +1 | โ1 |
| M | compiler/ml/external_ffi_types.mli | +1 | โ1 |
| M | compiler/ml/outcometree.ml | +7 | โ1 |
| M | compiler/ml/parsetree.ml | +6 | โ13 |
| M | compiler/ml/pprintast.ml | +1 | โ6 |
| M | compiler/ml/primitive.ml | +18 | โ15 |
| M | compiler/ml/primitive.mli | +20 | โ2 |
| M | compiler/ml/printast.ml | +1 | โ5 |
| M | compiler/ml/printtyped.ml | +1 | โ5 |
| M | compiler/ml/typedecl.ml | +23 | โ9 |
| M | compiler/ml/typedtree.ml | +1 | โ1 |
| M | compiler/ml/typedtree.mli | +1 | โ1 |
| M | compiler/syntax/src/res_core.ml | +2 | โ1 |
| M | compiler/syntax/src/res_outcome_printer.ml | +5 | โ5 |
| M | compiler/syntax/src/res_printer.ml | +2 | โ4 |
| A | tests/build_tests/super_errors/expected/warning_101_external_arg_attribute.res.expected | +26 | โ0 |
| A | tests/build_tests/super_errors/fixtures/warning_101_external_arg_attribute.res | +3 | โ0 |
| M | tests/ounit_tests/ounit_ast_mapper0_tests.ml | +32 | โ3 |
| M | tests/ounit_tests/ounit_string_literal_tests.ml | +7 | โ3 |
| A | tests/syntax_tests/data/ast-mapping/Externals.res | +11 | โ0 |
| A | tests/syntax_tests/data/ast-mapping/expected/Externals.res.txt | +11 | โ0 |