Corctions for #151 and #152
h3rald h3rald@h3rald.com
Sun, 07 Feb 2021 21:50:46 +0000
4 files changed,
11 insertions(+),
5 deletions(-)
M
minpkg/core/interpreter.nim
→
minpkg/core/interpreter.nim
@@ -4,6 +4,7 @@ strutils,
sequtils, os, critbits, + json, algorithm when defined(mini): import@@ -194,7 +195,7 @@ if not val.obj.isNil:
v.obj = val.obj return v -proc apply*(i: In, op: MinOperator) {.gcsafe, extern:"min_exported_symbol_$1".}= +proc apply*(i: In, op: MinOperator, sym = "") {.gcsafe, extern:"min_exported_symbol_$1".}= if op.kind == minProcOp: op.prc(i) else:@@ -202,6 +203,8 @@ if op.val.kind == minQuotation:
var newscope = newScopeRef(i.scope) i.withScope(newscope): for e in op.val.qVal: + if e.isSymbol and e.symVal == sym: + raiseInvalid("Symbol '$#' evaluates to itself" % sym) i.push e else: i.push(op.val)@@ -264,7 +267,7 @@ let symbol = val.symVal
if symbol == "return": raise MinReturnException(msg: "return symbol found") if i.scope.hasSymbol(symbol): - i.apply i.scope.getSymbol(symbol) + i.apply i.scope.getSymbol(symbol), symbol else: # Check if symbol ends with ! (auto-popping) if symbol.len > 1 and symbol[symbol.len-1] == '!':
M
minpkg/lib/min_lang.nim
→
minpkg/lib/min_lang.nim
@@ -501,7 +501,7 @@ symbol = sym.getString
when not defined(mini): if not symbol.match USER_SYMBOL_REGEX: raiseInvalid("Symbol identifier '$1' contains invalid characters." % symbol) - info "[lambd] $1 = $2" % [symbol, $q1] + info "[lambda] $1 = $2" % [symbol, $q1] if i.scope.symbols.hasKey(symbol) and i.scope.symbols[symbol].sealed: raiseUndefined("Attempting to redefine sealed symbol '$1'" % [symbol]) i.scope.symbols[symbol] = MinOperator(kind: minValOp, val: q1, sealed: false, quotation: true)
M
next-release.md
→
next-release.md
@@ -4,7 +4,10 @@ * #141 - The **'** symbol is now an alias of the **quotesym** symbol (but its behavior remains the same: it can be used to created quotes symbols from a string), and the **'** sigil is equivalent to the new **quotesym** symbol, not **quote**.
### Fixes +* #147 - Fixed an error when processing operator output values. * Now adding **help.json** to installation folder when installing via nimble. +* #151 - Added documentation for **integer**. +* #152 - Now preventing infinite recursion in case a symbol evaluates to itsel. ### New features
M
site/contents/reference-lang.md
→
site/contents/reference-lang.md
@@ -138,7 +138,7 @@ {#op||expect-empty-stack||{{none}}||{{none}}||
Raises an error if the stack is not empty.#} {#op||float||{{any}}||{{flt}}|| -> Converts {{any}} to an integer value based on the following rules: +> Converts {{any}} to a float value based on the following rules: > > * If {{any}} is {{t}}, it is converted to `1.0`. > * If {{any}} is {{f}}, it is converted to `0.0`.@@ -205,7 +205,7 @@ > >
> > (2 + 3 * 5) infix-dequote #} -{#op||int||{{any}}||{{i}}|| +{#op||integer||{{any}}||{{i}}|| > Converts {{any}} to an integer value based on the following rules: > > * If {{any}} is {{t}}, it is converted to `1`.