Skip to content

Commit

Permalink
fix: remove anonymous function from struct methods
Browse files Browse the repository at this point in the history
  • Loading branch information
llafuente committed Oct 23, 2024
1 parent 67b4952 commit 3c262a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
23 changes: 13 additions & 10 deletions spec/language/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,30 @@ 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
: memoryFunctionDef functionBody
;

memoryFunctionDef
: ('new'|'delete'|'clone') '(' functionParameterList? ')'
: ('override' | 'overwrite')* ('new'|'delete'|'clone') '(' functionParameterList? ')'
;

operatorFunctionDecl
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
```
```
9 changes: 3 additions & 6 deletions spec/language/type-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ typeImplementsDecl
;

structTypeDecl
: 'struct' (typeExtendsDecl | typeImplementsDecl)* '{' endOfStmt? structProperty* '}'
: 'struct' (typeExtendsDecl | typeImplementsDecl | 'noalign')* '{' endOfStmt? structProperty* '}'
;

interfaceTypeDecl
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3c262a9

Please sign in to comment.