summaryrefslogtreecommitdiff
path: root/src/texec
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-12-14 17:22:16 -0500
committerKyle Gunger <kgunger12@gmail.com>2022-12-14 17:22:16 -0500
commit0f1faa877167324c52f2626cebe335a85cae40d9 (patch)
tree51d91e7a9e9490f4b5f35bc79fc29be5a7e80b52 /src/texec
parent64d8a228f4407bddea8be60e4657f04a49b1c35a (diff)
Bugfix: Types in types
+ Fix for structs where a member's type was unable to be determined
Diffstat (limited to 'src/texec')
-rw-r--r--src/texec/eval.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/texec/eval.go b/src/texec/eval.go
index b0f4a47..47a379e 100644
--- a/src/texec/eval.go
+++ b/src/texec/eval.go
@@ -239,7 +239,7 @@ func searchNode(s TArtifact) (*tparse.Node, TArtifact) {
return nil, tNull.T
}
-func searchDef(s TArtifact) *TVariable {
+func searchDef(s TArtifact) (*TVariable, TArtifact) {
// i-- because of reverse lookup
for i := len(cart.Path); i >= 0; i-- {
@@ -253,10 +253,13 @@ func searchDef(s TArtifact) *TVariable {
ret := getDef(tst, s.Name)
if ret != nil {
- return ret
+ pth := []string{}
+ pth = append(pth, cart.Path[:i]...)
+ pth = append(pth, s.Path...)
+ return ret, TArtifact{ pth , s.Name }
}
}
- return nil
+ return nil, tNull.T
}
// End block of complexity horror
@@ -463,7 +466,7 @@ func getLiteralType(v tparse.Node) TType {
// Convert Value to Struct from Array (cvsa)
// USE ONLY IN THE CASE OF tStruct!
func cvsa(sct TArtifact, dat []interface{}) VarMap {
- sv := searchDef(sct)
+ sv, sct := searchDef(sct)
old_c := cart
cart = sct
@@ -516,8 +519,7 @@ func cata(st TArtifact, dat []interface{}) []interface{} {
// Copy struct to struct
// Makes a deep copy of a struct.
func csts(st TArtifact, dat VarMap) VarMap {
- sv := searchDef(st)
-
+ sv, st := searchDef(st)
old_c := cart
cart = st
@@ -678,7 +680,7 @@ func resolveArtifact(a TArtifact, ctx *VarMap) *TVariable {
val, prs := (*ctx)[a.Name]
if !prs || len(a.Path) != 0 {
// Try searching the modules for it
- val = searchDef(a)
+ val, _ = searchDef(a)
}
return val
}