From 396bb5eed03d03ea6fd83019cb6f2257fed47671 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Wed, 3 Jan 2024 15:28:51 +0100 Subject: [PATCH] FunctionPrototype: add another analysis check --- src/analysis.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/analysis.cpp b/src/analysis.cpp index abb3f80..bee7c32 100644 --- a/src/analysis.cpp +++ b/src/analysis.cpp @@ -277,6 +277,13 @@ AnalysisResult analyze(Node &ast, Memory &memory) { throw RuntimeError(ErrorType::NestedFunction, token.pos, {}); } catch (const InternalError& _) {} + if (memory.contains(function_name)) { + // Il existe une variable non fonction à ce nom + if (memory.get(function_name).type.type != TypeType::Function) { + throw RuntimeError(ErrorType::IncompatibleRedefinition, token.pos, function_name); + } + } + memory.declare(function_name, { .type = TypeType::Function, .data = make_fn_prototype(node)