Skip to content

Commit 3d1ec97

Browse files
committed
Resolve block enum types using callee script owner
1 parent e959035 commit 3d1ec97

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

vibes/execution.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ type capabilityContractScope struct {
6666
}
6767

6868
type moduleContext struct {
69-
key string
70-
path string
71-
root string
69+
key string
70+
path string
71+
root string
72+
script *Script
7273
}
7374

7475
type callFrame struct {

vibes/execution_blocks.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import "fmt"
55
func (exec *Execution) evalBlockLiteral(block *BlockLiteral, env *Env) (Value, error) {
66
blockValue := NewBlock(block.Params, block.Body, env)
77
blk := blockValue.Block()
8-
blk.owner = exec.script
8+
if ctx := exec.currentModuleContext(); ctx != nil && ctx.script != nil {
9+
blk.owner = ctx.script
10+
} else {
11+
blk.owner = exec.script
12+
}
913
if ctx := exec.currentModuleContext(); ctx != nil {
1014
blk.moduleKey = ctx.key
1115
blk.modulePath = ctx.path
@@ -33,9 +37,10 @@ func (exec *Execution) CallBlock(block Value, args []Value) (Value, error) {
3337
}
3438
blk := block.Block()
3539
exec.pushModuleContext(moduleContext{
36-
key: blk.moduleKey,
37-
path: blk.modulePath,
38-
root: blk.moduleRoot,
40+
key: blk.moduleKey,
41+
path: blk.modulePath,
42+
root: blk.moduleRoot,
43+
script: blk.owner,
3944
})
4045
defer exec.popModuleContext()
4146

vibes/execution_calls.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ func (exec *Execution) callFunction(fn *ScriptFunction, receiver Value, args []V
163163
ctx := moduleContext{}
164164
if fn.owner != nil {
165165
ctx = moduleContext{
166-
key: fn.owner.moduleKey,
167-
path: fn.owner.modulePath,
168-
root: fn.owner.moduleRoot,
166+
key: fn.owner.moduleKey,
167+
path: fn.owner.modulePath,
168+
root: fn.owner.moduleRoot,
169+
script: fn.owner,
169170
}
170171
}
171172
exec.pushModuleContext(ctx)

0 commit comments

Comments
 (0)