add paster to some weird golang incorrect memory address bug

This commit is contained in:
2023-11-14 20:19:24 +00:00
parent 140ce3d2a8
commit 6295e23d1b
3 changed files with 31 additions and 9 deletions

View File

@@ -20,11 +20,11 @@ func isDoWrap(code UNPARSEcode) bool {
func parseDoWrap(code UNPARSEcode, index int, codelines []UNPARSEcode) (any, bool, ArErr, int) {
currentindent := len(code.realcode) - len(strings.TrimLeft(code.realcode, " "))
var setindent int = -1
var i = index + 1
translated := []any{}
for i < len(codelines) {
var allCodelines = []UNPARSEcode{}
i := index + 1
for ; i < len(codelines); i++ {
if isBlank(codelines[i]) {
i++
continue
}
indent := len(codelines[i].code) - len(strings.TrimLeft(codelines[i].code, " "))
@@ -34,6 +34,13 @@ func parseDoWrap(code UNPARSEcode, index int, codelines []UNPARSEcode) (any, boo
if indent <= currentindent {
break
}
allCodelines = append(allCodelines, codelines[i])
}
finalLines := i
codelines = allCodelines
translated := []any{}
for i := 0; i < len(codelines); {
indent := len(codelines[i].code) - len(strings.TrimLeft(codelines[i].code, " "))
if indent != setindent {
return nil, false, ArErr{"Syntax Error", "invalid indent", i, code.path, codelines[i].code, true}, 1
}
@@ -45,13 +52,15 @@ func parseDoWrap(code UNPARSEcode, index int, codelines []UNPARSEcode) (any, boo
}
translated = append(translated, val)
}
return dowrap{run: translated, line: code.line, path: code.path, code: code.realcode}, true, ArErr{}, i - index
return dowrap{run: translated, line: code.line, path: code.path, code: code.realcode}, true, ArErr{}, finalLines - index
}
func runDoWrap(d dowrap, stack stack, stacklevel int) (any, ArErr) {
newstack := append(stack, newscope())
func runDoWrap(d dowrap, Stack stack, stacklevel int) (any, ArErr) {
newstack := append(Stack, newscope())
for _, v := range d.run {
val, err := runVal(v, newstack, stacklevel+1)
newstackCopy := make(stack, len(newstack))
copy(newstackCopy, newstack)
val, err := runVal(v, newstackCopy, stacklevel+1)
if err.EXISTS {
return nil, err
}

View File

@@ -6,7 +6,7 @@ import (
)
// args without the program path
var Args = os.Args[1:]
var Args = []string{"/home/william/Documents/code/argon-v3/tests/broken_funcCall.ar"}
type stack = []ArObject

13
tests/broken_funcCall.ar Normal file
View File

@@ -0,0 +1,13 @@
let x = do
let class = {}
class.f(path) = do
let wowww = {}
wowww.nice(callback) = term.log(callback)
return wowww
class.cool(path, callback) = do
term.log(path,callback)
let c = (class.f(path))
c.nice(callback)
return class.object()
x.cool("to", ()=10)