mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 13:06:30 +00:00
builtins ignore type check
This commit is contained in:
parent
4a9d501a71
commit
a6da283b0a
@ -121,7 +121,13 @@ export class Checker {
|
||||
}
|
||||
const { returnType } = stmt.kind.vtype!;
|
||||
this.fnReturnStack.push(returnType);
|
||||
|
||||
const isBuiltin = stmt.kind.anno && stmt.kind.anno.ident === "builtin";
|
||||
if (isBuiltin) {
|
||||
stmt.kind.body.kind = { type: "block", stmts: [] };
|
||||
}
|
||||
const body = this.checkExpr(stmt.kind.body);
|
||||
|
||||
this.fnReturnStack.pop();
|
||||
if (!vtypesEqual(returnType, body)) {
|
||||
this.report(
|
||||
|
@ -15,9 +15,8 @@ const lexer = new Lexer(text, reporter);
|
||||
const parser = new Parser(lexer, reporter);
|
||||
const ast = parser.parseStmts();
|
||||
|
||||
console.log(JSON.stringify(ast, null, 4));
|
||||
// console.log(JSON.stringify(ast, null, 4));
|
||||
|
||||
/*
|
||||
new Resolver(reporter).resolve(ast);
|
||||
new Checker(reporter).check(ast);
|
||||
|
||||
@ -34,4 +33,3 @@ const program = lowerer.finish();
|
||||
console.log(JSON.stringify(program));
|
||||
|
||||
await Deno.writeTextFile("out.slgbc", JSON.stringify(program));
|
||||
*/
|
||||
|
@ -1,4 +1,6 @@
|
||||
fn print(msg: string) #[builtin(print)] {}
|
||||
fn print(msg: string) #[builtin(print)] {
|
||||
+ "hello" 0
|
||||
}
|
||||
|
||||
fn main() {
|
||||
print("hello world!");
|
||||
|
Loading…
Reference in New Issue
Block a user