all repos — min @ 6a532ba968babc46403fc1eb8efa997ca10e03d4

A small but practical concatenative programming language.

Fixes and improvements.
h3rald h3rald@h3rald.com
Wed, 30 Dec 2020 13:37:04 +0100
commit

6a532ba968babc46403fc1eb8efa997ca10e03d4

parent

236b5984e26d31253276e297dd2160a1b957c356

3 files changed, 8 insertions(+), 8 deletions(-)

jump to
M core/interpreter.nimcore/interpreter.nim

@@ -230,7 +230,6 @@ proc push*(i: In, val: MinValue) {.gcsafe, extern:"min_exported_symbol_$1".}=

if val.kind == minSymbol: i.debug(val) if not i.evaluating: - #echo val, ":", val.filename, ":", val.line, ":", val.column if val.line == 0 and val.column == 0 and val.filename == "": # Simbol was added via min code, get data from previous min symbol var nval = deepCopy(val)

@@ -287,7 +286,6 @@ template handleErrors*(i: In, body: untyped) =

try: body except MinRuntimeError: - echo "runtime" let msg = getCurrentExceptionMsg() i.stack = i.stackcopy error("$1:$2,$3 $4" % [i.currSym.filename, $i.currSym.line, $i.currSym.column, msg])

@@ -295,15 +293,11 @@ i.stackTrace()

i.trace = @[] raise MinTrappedException(msg: msg) except MinTrappedException: - echo "trapped" raise except: let msg = getCurrentExceptionMsg() i.stack = i.stackcopy - echo "generic " - #echo("$1:$2,$3 $4" % [i.currSym.filename, $i.currSym.line, $i.currSym.column, msg]) - #i.error(msg) - error("$1:$2,$3 $4" % [i.currSym.filename, $i.currSym.line, $i.currSym.column, msg]) + i.error(msg) i.stackTrace() i.trace = @[] raise MinTrappedException(msg: msg)

@@ -405,10 +399,13 @@ contents = ";;\n" & fileLines[1..fileLines.len-1].join("\n")

else: contents = fileLines.join("\n") var i2 = i.copy(s) + let snapshot = deepCopy(i.stack) i2.withScope: i2.open(newStringStream(contents), s) discard i2.parser.getToken() discard i2.interpret(parseOnly) + if snapshot != i2.stack: + raiseInvalid("Code in required file '$#' is polluting the stack" % s) result = newDict(i2.scope) result.objType = "module" for key, value in i2.scope.symbols.pairs:
M lib/min_lang.nimlib/min_lang.nim

@@ -393,7 +393,7 @@ let pair = line.split(":")

if pair.len == 1 and pair[0].len == 0: continue i.dset(dict, pair[0].strip, pair[1].strip.newVal) - i.push(dict) + i.push(dict) except: raiseInvalid("Invalid/unsupported YAML object (only dictionaries with string values are supported)")
M next-release.mdnext-release.md

@@ -2,3 +2,6 @@ * **REMOVED** support for creating dynamic libraries (it never worked properly anyway)

* Added **operator** symbol to define symbols and sigils in a more controlled way. * Added **expect-all** and **expect-any** symbols. * Fixed behavior of **require** and **invoke** ensuring that operators are evaluated in the correct scopes. +* Improved diagnostics of exceptions occurring in native code. +* Fixed unwanted stack pollution in **to-yaml** operator. +* Added check to prevent required modules from polluting the stack.