mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
Implement setting of variables in other modules correctly.
This fixes #141.
This commit is contained in:
parent
2cdbf67147
commit
2e08ae0975
|
@ -312,11 +312,18 @@ func (cp *compiler) singleVariable(n *parse.Indexing, msg string) VariableOp {
|
||||||
}
|
}
|
||||||
variable := ec.ResolveVar(ns, barename)
|
variable := ec.ResolveVar(ns, barename)
|
||||||
if variable == nil {
|
if variable == nil {
|
||||||
// New variable.
|
if ns == "" || ns == "local" {
|
||||||
// XXX We depend on the fact that this variable will
|
// New variable.
|
||||||
// immeidately be set.
|
// XXX We depend on the fact that this variable will
|
||||||
variable = NewPtrVariable(nil)
|
// immeidately be set.
|
||||||
ec.local[barename] = variable
|
variable = NewPtrVariable(nil)
|
||||||
|
ec.local[barename] = variable
|
||||||
|
} else if mod, ok := ec.modules[ns]; ok {
|
||||||
|
variable = NewPtrVariable(nil)
|
||||||
|
mod[barename] = variable
|
||||||
|
} else {
|
||||||
|
ec.errorf(p, "cannot set $%s", varname)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return variable
|
return variable
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user