diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-05-17 16:19:33 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-05-17 16:19:33 +0330 |
commit | cfc5418931fa15e6a31583820266bf35d489da88 (patch) | |
tree | cbfbf5f8357277613dac08dd3a17a420d4396c0b /src/runner | |
parent | 62090a4830bd9f01e56b08f50d502d680be9d1de (diff) |
fix memory leaks and shape shifter
Diffstat (limited to 'src/runner')
-rw-r--r-- | src/runner/runner.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/runner/runner.c b/src/runner/runner.c index 0fbfbf2..67fc02e 100644 --- a/src/runner/runner.c +++ b/src/runner/runner.c @@ -1096,19 +1096,26 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet, function->token <= AST_TREE_TOKEN_BUILTIN_END) { for (size_t i = 0; i < args_size; ++i) { AstTreeFunctionCallParam param = metadata->parameters[i]; - args[i] = getForVariable(param.value, scope, shouldRet, false, - isComptime, breakCount, shouldContinue, false); - if (discontinue(*shouldRet, *breakCount)) { - astTreeDelete(function); - for (size_t j = 0; j < i; ++j) { - astTreeDelete(args[i]); + if (function->token != AST_TREE_TOKEN_BUILTIN_TYPE_OF) { + args[i] = + getForVariable(param.value, scope, shouldRet, false, isComptime, + breakCount, shouldContinue, false); + if (discontinue(*shouldRet, *breakCount)) { + astTreeDelete(function); + for (size_t j = 0; j < i; ++j) { + astTreeDelete(args[i]); + } + return args[i]; } - return args[i]; + } else { + args[i] = param.value; } } result = runAstTreeBuiltin(function, scope, args); - for (size_t i = 0; i < args_size; ++i) { - astTreeDelete(args[i]); + if (function->token != AST_TREE_TOKEN_BUILTIN_TYPE_OF) { + for (size_t i = 0; i < args_size; ++i) { + astTreeDelete(args[i]); + } } } else { UNREACHABLE; |