diff --git a/anselme/ast/Function.lua b/anselme/ast/Function.lua index 9ef9a1c..a8085df 100644 --- a/anselme/ast/Function.lua +++ b/anselme/ast/Function.lua @@ -27,6 +27,16 @@ Function = ast.abstract.Overloadable { return Function:new(parameters, ReturnBoundary:new(expression)) end, + -- returns the same function, without the return boundary + -- this does not create a new function scope + without_return_boundary = function(self) + if ReturnBoundary:is(self.expression) then + return Function:new(self.parameters, self.expression.expression, self.scope, self.upvalues) + else + return self + end + end, + _format = function(self, ...) if self.parameters.assignment then return "$"..self.parameters:format_short(...).."; "..self.expression:format_right(...) diff --git a/anselme/stdlib/function.lua b/anselme/stdlib/function.lua index 570134d..f08a49e 100644 --- a/anselme/stdlib/function.lua +++ b/anselme/stdlib/function.lua @@ -26,6 +26,13 @@ return { end }, + { + "keep return", "(f::is function)", + function(state, f) + return f:without_return_boundary() + end + }, + { "_._", "(c::is function, s::is string)", function(state, c, s) diff --git a/anselme/stdlib/language/frFR.lua b/anselme/stdlib/language/frFR.lua index 4463953..09c8d47 100644 --- a/anselme/stdlib/language/frFR.lua +++ b/anselme/stdlib/language/frFR.lua @@ -12,6 +12,7 @@ return [[ :@défini = stdlib.defined :@surcharge = stdlib.overload +:@préserver retour = stdlib.keep return :@si = stdlib.if :@sinon = stdlib.else