diff --git a/src/compiler.c b/src/compiler.c index 171214a..9cf1891 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -3623,10 +3623,20 @@ ResultType(CometOperand, ErrorMessage) visitMethodDefStatement(CometCompiler* c, false ); - // build the functions body - ResultType(CometOperand, ErrorMessage) bodyResult = compile(c, funcDef.program); - if (bodyResult.error) - return bodyResult; + if (funcDef.inlineExpr != NULL) { // its an inline function + // build the functions body + ResultType(CometOperand, ErrorMessage) exprResult = compile(c, funcDef.inlineExpr); + if (exprResult.error) + return exprResult; + + // then return + buildReturn(c); + } else { + // build the functions body + ResultType(CometOperand, ErrorMessage) bodyResult = compile(c, funcDef.program); + if (bodyResult.error) + return bodyResult; + } // return back to the parent scope c->env = destroyEnv(c->env); diff --git a/test.comet b/test.comet index 6c3bed2..e69de29 100644 --- a/test.comet +++ b/test.comet @@ -1,27 +0,0 @@ -struct Foo { - init() { - - } - - func foo() -> int { - return 2 + 6 - } -} - -struct Child : Foo { - override func foo() -> int { - return 2 + 4 - } - - init() { - - } - - -} - -func main() -> int { - Child test = new Child() - - return test.foo() -} \ No newline at end of file