@@ -88,7 +88,7 @@ static int analyze_function(SemanticInfo *info, AstFunction *fn)
8888 symbol_table_free (& symbols );
8989 return 0 ;
9090 }
91- if (!symbol_table_add (& symbols , param -> name , param -> type , 0 , 0 , TYPE_UNKNOWN ))
91+ if (!symbol_table_add (& symbols , param -> name , param -> type , 0 , 0 , TYPE_UNKNOWN , NULL ))
9292 {
9393 semantic_error ("duplicate parameter '%s' in function '%s'" , param -> name , fn -> name );
9494 symbol_table_free (& symbols );
@@ -222,7 +222,7 @@ static int analyze_statement(SemanticInfo *info, AstFunction *fn, SymbolTable *s
222222 }
223223 else
224224 {
225- if (!symbol_table_add (symbols , stmt -> data .decl .name , stmt -> data .decl .type , 0 , 0 , TYPE_UNKNOWN ))
225+ if (!symbol_table_add (symbols , stmt -> data .decl .name , stmt -> data .decl .type , 0 , 0 , TYPE_UNKNOWN , stmt ))
226226 {
227227 semantic_error ("duplicate declaration of '%s' in function '%s'" , stmt -> data .decl .name , fn -> name );
228228 return 0 ;
@@ -451,6 +451,15 @@ static TypeKind analyze_expression(SemanticInfo *info, SymbolTable *symbols, Ast
451451 expr -> type = symbol -> type ;
452452 return expr -> type ;
453453 }
454+ if (symbol -> stmt_ref )
455+ {
456+ symbol -> stmt_ref -> data .decl .is_used = 1 ;
457+ }
458+ // ---------------------------
459+
460+ expr -> type = symbol -> type ;
461+ return expr -> type ;
462+ }
454463 case EXPR_SUBSCRIPT :
455464 {
456465 AstExpr * array_expr = expr -> data .subscript .array ;
0 commit comments