diff options
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c index 100916b..2bf95d4 100644 --- a/src/parser.c +++ b/src/parser.c | |||
@@ -569,6 +569,7 @@ parse(Token *tokens, Errors *errors) { | |||
569 | 569 | ||
570 | // Prepare global environment of builtin functions. | 570 | // Prepare global environment of builtin functions. |
571 | Environment *global_env = env_alloc(NULL); | 571 | Environment *global_env = env_alloc(NULL); |
572 | Environment *env = env_alloc(global_env); | ||
572 | size_t n_builtins = sizeof(builtins) / sizeof(char*); | 573 | size_t n_builtins = sizeof(builtins) / sizeof(char*); |
573 | for (size_t i = 0; i < n_builtins; i++) { | 574 | for (size_t i = 0; i < n_builtins; i++) { |
574 | // Prepare builtin symbol. | 575 | // Prepare builtin symbol. |
@@ -600,7 +601,7 @@ parse(Token *tokens, Errors *errors) { | |||
600 | } | 601 | } |
601 | } | 602 | } |
602 | array_push(final_roots, root); | 603 | array_push(final_roots, root); |
603 | semantic_analysis(global_env, root, errors); | 604 | semantic_analysis(env, root, errors); |
604 | if (errors->n != 0) { | 605 | if (errors->n != 0) { |
605 | array_free(final_roots); | 606 | array_free(final_roots); |
606 | return (Program){0}; | 607 | return (Program){0}; |
@@ -614,7 +615,7 @@ parse(Token *tokens, Errors *errors) { | |||
614 | // TODO: Type check basic expressions (e.g. arithmetic/numeric comparisons). | 615 | // TODO: Type check basic expressions (e.g. arithmetic/numeric comparisons). |
615 | // We can't be sure when we have functions unless the return type is known. | 616 | // We can't be sure when we have functions unless the return type is known. |
616 | 617 | ||
617 | return (Program){roots, global_env}; | 618 | return (Program){roots, env}; |
618 | } | 619 | } |
619 | 620 | ||
620 | Environment * | 621 | Environment * |