make even negative sign not allow any type

This commit is contained in:
2023-06-21 08:58:13 +01:00
parent 6495e7f9b9
commit ae08f059fb
2 changed files with 6 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ var negativeCompile = makeRegex(`( *)-(.|\n)+( *)`)
type negative struct { type negative struct {
VAL any VAL any
sign bool
line int line int
code string code string
path string path string
@@ -26,11 +27,9 @@ func parseNegative(code UNPARSEcode, index int, codeline []UNPARSEcode) (any, bo
path: code.path, path: code.path,
}, index, codeline, 0) }, index, codeline, 0)
if difference%2 == 0 {
return resp, worked, err, i
}
return negative{ return negative{
VAL: resp, VAL: resp,
sign: difference%2 == 0,
line: code.line, line: code.line,
code: code.realcode, code: code.realcode,
path: code.path, path: code.path,

View File

@@ -70,7 +70,10 @@ func runVal(line any, stack stack, stacklevel int) (any, ArErr) {
} }
switch y := resp.(type) { switch y := resp.(type) {
case number: case number:
return newNumber().Neg(y), ArErr{} if !x.sign {
return newNumber().Neg(y), ArErr{}
}
return y, ArErr{}
} }
return nil, ArErr{ return nil, ArErr{
TYPE: "TypeError", TYPE: "TypeError",