mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
make even negative sign not allow any type
This commit is contained in:
@@ -6,6 +6,7 @@ var negativeCompile = makeRegex(`( *)-(.|\n)+( *)`)
|
||||
|
||||
type negative struct {
|
||||
VAL any
|
||||
sign bool
|
||||
line int
|
||||
code string
|
||||
path string
|
||||
@@ -26,11 +27,9 @@ func parseNegative(code UNPARSEcode, index int, codeline []UNPARSEcode) (any, bo
|
||||
path: code.path,
|
||||
}, index, codeline, 0)
|
||||
|
||||
if difference%2 == 0 {
|
||||
return resp, worked, err, i
|
||||
}
|
||||
return negative{
|
||||
VAL: resp,
|
||||
sign: difference%2 == 0,
|
||||
line: code.line,
|
||||
code: code.realcode,
|
||||
path: code.path,
|
||||
|
||||
@@ -70,8 +70,11 @@ func runVal(line any, stack stack, stacklevel int) (any, ArErr) {
|
||||
}
|
||||
switch y := resp.(type) {
|
||||
case number:
|
||||
if !x.sign {
|
||||
return newNumber().Neg(y), ArErr{}
|
||||
}
|
||||
return y, ArErr{}
|
||||
}
|
||||
return nil, ArErr{
|
||||
TYPE: "TypeError",
|
||||
message: "cannot negate a non-number",
|
||||
|
||||
Reference in New Issue
Block a user