From 3c262a90641d972211d3d7c3c8a6ec1f255fc9a0 Mon Sep 17 00:00:00 2001 From: llafuente Date: Wed, 23 Oct 2024 20:56:19 +0200 Subject: [PATCH] fix: remove anonymous function from struct methods --- spec/language/functions.md | 23 +++++++++++++---------- spec/language/type-system.md | 9 +++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/language/functions.md b/spec/language/functions.md index 70d6fbd..89dd740 100644 --- a/spec/language/functions.md +++ b/spec/language/functions.md @@ -21,19 +21,22 @@ deferStmt functionDecl : (functionDef | anonymousFunctionDef) functionBody ; -/* + functionModifiers - : '@pure' - | '@mock' - | '@debug' + : 'pure' + | 'override' + | 'overwrite' + | 'readonly' ; -*/ + // | '@mock' + // | '@debug' + anonymousFunctionDef - : 'pure'? 'function' templateDefinition? '(' functionParameterList? ')' functionReturnTypeModifiers* typeDefinition? + : functionModifiers* 'function' templateDefinition? '(' functionParameterList? ')' functionReturnTypeModifiers* typeDefinition? ; functionDef - : 'pure'? 'function' identifier templateDefinition? '(' functionParameterList? ')' functionReturnTypeModifiers* typeDefinition? + : functionModifiers* 'function' identifier templateDefinition? '(' functionParameterList? ')' functionReturnTypeModifiers* typeDefinition? ; memoryFunctionDecl @@ -41,7 +44,7 @@ memoryFunctionDecl ; memoryFunctionDef - : ('new'|'delete'|'clone') '(' functionParameterList? ')' + : ('override' | 'overwrite')* ('new'|'delete'|'clone') '(' functionParameterList? ')' ; operatorFunctionDecl @@ -224,7 +227,7 @@ function sum(i32 a, i32 b) i32 { 1. A pure function shall have no access to package, file or global variables unless it's a constant or a semantic-error shall raise -> A pure function shall no read or write any non-constant variable. +> A pure function shall no read or write any non-constant variable outside function scope ## functions as Type @@ -1181,4 +1184,4 @@ function add<$t>($t a, float b) $t { function add<$t is float>($t a, float b) $t { return a + b } -``` \ No newline at end of file +``` diff --git a/spec/language/type-system.md b/spec/language/type-system.md index 057ad7e..eb020f7 100644 --- a/spec/language/type-system.md +++ b/spec/language/type-system.md @@ -130,7 +130,7 @@ typeImplementsDecl ; structTypeDecl - : 'struct' (typeExtendsDecl | typeImplementsDecl)* '{' endOfStmt? structProperty* '}' + : 'struct' (typeExtendsDecl | typeImplementsDecl | 'noalign')* '{' endOfStmt? structProperty* '}' ; interfaceTypeDecl @@ -175,16 +175,13 @@ structPropertyModifiers | 'readonly' ; -functionModifiers - : 'readonly' - ; - structPropertyDecl // TODO anonymousFunction : (structPropertyModifiers)* typeDefinition identifier ('=' (constant | arrayConstantInitializer | structConstantInitializer))? // TODO REVIEW aliasing operator? | propertyAlias - | (functionModifiers)* functionDecl + // Notice: do not support anonymous function + | functionDef functionBody | memoryFunctionDecl | operatorFunctionDecl | structGetterDecl