Skip to content

Commit

Permalink
stability fix in put expr
Browse files Browse the repository at this point in the history
  • Loading branch information
reginaldford committed Nov 24, 2024
1 parent a922230 commit 797aa07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CC_DEBUG := clang
CC_PROF := clang
CC_UNIFIED := zig cc
CFLAGS_UNIFIED := -Oz -static
CFLAGS := -Ofast -Wall
CFLAGS := -O3 -Wall
CFLAGS_DEBUG := -g
CFLAGS_PROF := -fprofile-instr-generate -fcoverage-mapping
LDFLAGS := -lm
Expand Down
10 changes: 3 additions & 7 deletions src/main/engine/sm_ast_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1730,13 +1730,9 @@ sm_object *sm_engine_eval(sm_object *input, sm_cx *current_cx, sm_expr *sf) {
case SM_PUT_EXPR: {
sm_string *str;
for (int i = 0; i < sme->size; i++) {
sm_object *evaluated = sm_engine_eval(sm_expr_get_arg(sme, i), current_cx, sf);
if (!expect_type(evaluated, SM_STRING_TYPE)) {
sm_symbol *title = sm_new_symbol("typeMismatch", 12);
sm_string *message = sm_new_fstring_at(
sms_heap, "put function takes strings, but parameter %i was not a string", i);
return ((sm_object *)sm_new_error_from_expr(title, message, sme, NULL));
}
sm_object *evaluated = eager_type_check(sme, i, SM_STRING_TYPE, current_cx, sf);
if (evaluated->my_type != SM_STRING_TYPE)
return evaluated;
str = (sm_string *)evaluated;
for (uint32_t i = 0; i < str->size; i++)
putchar((&str->content)[i]);
Expand Down

0 comments on commit 797aa07

Please sign in to comment.