feat: add extern let declarations for JS FFI
Add support for `extern let name: Type` and `extern let name: Type = "jsName"` syntax for declaring external JavaScript values. This follows the same pattern as extern fn across all compiler passes: parser, typechecker, interpreter (runtime error placeholder), JS backend (emits JS name directly without mangling), formatter, linter, modules, and symbol table. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1431,6 +1431,14 @@ impl Interpreter {
|
||||
Ok(Value::Unit)
|
||||
}
|
||||
|
||||
Declaration::ExternLet(ext) => {
|
||||
// Register a placeholder that errors at runtime (extern lets only work in JS)
|
||||
let name = ext.name.name.clone();
|
||||
self.global_env
|
||||
.define(&name, Value::ExternFn { name: name.clone(), arity: 0 });
|
||||
Ok(Value::Unit)
|
||||
}
|
||||
|
||||
Declaration::Effect(_) | Declaration::Trait(_) | Declaration::Impl(_) => {
|
||||
// These are compile-time only
|
||||
Ok(Value::Unit)
|
||||
|
||||
Reference in New Issue
Block a user