all repos — min @ fd17bb85e8ee10e1ad7868e0fcdb2f478e7c34a4

A small but practical concatenative programming language.

Fixed incorrect override propagation. (#133)
h3rald h3rald@h3rald.com
Wed, 03 Feb 2021 02:29:17 +0000
commit

fd17bb85e8ee10e1ad7868e0fcdb2f478e7c34a4

parent

350b3490dcbcfd1e9a739830391392dca72c26cf

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

jump to
M minpkg/core/interpreter.nimminpkg/core/interpreter.nim

@@ -267,7 +267,7 @@ if i.scope.hasSymbol(symbol):

i.apply i.scope.getSymbol(symbol) else: # Check if symbol ends with ! (auto-popping) - if symbol.len > 1 and symbol[symbol.len-1] == '!': + if symbol.len > 2 and symbol[symbol.len-1] == '!': let apSymbol = symbol[0..symbol.len-2] if i.scope.hasSymbol(apSymbol): i.apply i.scope.getSymbol(apSymbol)
M minpkg/core/scope.nimminpkg/core/scope.nim

@@ -42,13 +42,13 @@ result = false

# check if a symbol already exists in current scope if not scope.isNil and scope.symbols.hasKey(key): if not override and scope.symbols[key].sealed: - raiseInvalid("Symbol '$1' is sealed." % key) + raiseInvalid("Symbol '$1' is sealed ." % key) scope.symbols[key] = value result = true else: # Go up the scope chain and attempt to find the symbol if not scope.parent.isNil: - result = scope.parent.setSymbol(key, value) + result = scope.parent.setSymbol(key, value, override) proc getSigil*(scope: ref MinScope, key: string): MinOperator = if scope.sigils.hasKey(key):

@@ -93,4 +93,4 @@ proc previous*(scope: ref MinScope): ref MinScope =

if scope.parent.isNil: return scope else: - return scope.parent+ return scope.parent
M minpkg/lib/min_lang.nimminpkg/lib/min_lang.nim

@@ -921,14 +921,14 @@ let vals = i.expect("'sym")

let sym = vals[0].getString var s = i.scope.getSymbol(sym) s.sealed = true - i.scope.setSymbol(sym, s) + i.scope.setSymbol(sym, s, true) def.symbol("seal-sigil") do (i: In): let vals = i.expect("'sym") let sym = vals[0].getString var s = i.scope.getSigil(sym) s.sealed = true - i.scope.setSigil(sym, s) + i.scope.setSigil(sym, s, true) def.symbol("unseal-symbol") do (i: In): let vals = i.expect("'sym")