Fix assign cloning in SPython visitor (#3367)

This commit is contained in:
Александр Земляк 2026-01-02 19:16:52 +03:00 committed by GitHub
parent 34f05622a7
commit c33ba11b15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,6 +53,16 @@ namespace Languages.SPython.Frontend.Converters
private void BuildMainFunction(statement_list _statement_list)
{
statement_list mainBody = _statement_list.TypedClone();
// Нужно поправить это клонирование
for (var i = 0; i < _statement_list.Count; i++)
{
if (_statement_list[i] is assign ass && ass.first_assignment_defines_type)
{
((assign)mainBody[i]).first_assignment_defines_type = true;
}
}
mainBody.source_context = mainBody.Parent.source_context; // source context для MAIN охватывает весь файл
procedure_header _procedure_header = new procedure_header(mainFunctionName);
block _block = new block(null, mainBody, mainBody.source_context);