Removed set and upgraded Go to 1.24
All checks were successful
Test / build (push) Successful in 1m1s
All checks were successful
Test / build (push) Successful in 1m1s
This commit is contained in:
parent
0cf2f816da
commit
2e8e60f904
|
@ -14,7 +14,7 @@ jobs:
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.22.4
|
go-version: 1.24
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21.1
|
node-version: 21.1
|
||||||
|
|
|
@ -180,64 +180,6 @@ func modBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
|
||||||
return IntObject(n), nil
|
return IntObject(n), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this may need to be a macro
|
|
||||||
func setBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
|
|
||||||
if err := args.expectArgn(2); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
name, err := args.stringArg(0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else if len(name) == 0 {
|
|
||||||
return nil, fmt.Errorf("attempt to set empty string")
|
|
||||||
}
|
|
||||||
|
|
||||||
newVal := args.args[1]
|
|
||||||
|
|
||||||
if strings.HasPrefix(name, "@") {
|
|
||||||
pname := name[1:]
|
|
||||||
pvar, ok := args.ec.getPseudoVar(pname)
|
|
||||||
if ok {
|
|
||||||
if err := pvar.set(ctx, pname, newVal); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return newVal, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if pvar := args.inst.missingPseudoVarHandler; pvar != nil {
|
|
||||||
if err := pvar.set(ctx, pname, newVal); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return newVal, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("attempt to set '%v' to a non-existent pseudo-variable", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
args.ec.setOrDefineVar(name, newVal)
|
|
||||||
return newVal, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func mustSetBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
|
|
||||||
if err := args.expectArgn(2); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
name, err := args.stringArg(0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
newVal := args.args[1]
|
|
||||||
if newVal == nil {
|
|
||||||
return nil, fmt.Errorf("attempt to set '%v' to a nil value", args.args[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
args.ec.setOrDefineVar(name, newVal)
|
|
||||||
return newVal, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func eqBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
|
func eqBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
|
||||||
if err := args.expectArgn(2); err != nil {
|
if err := args.expectArgn(2); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -57,8 +57,6 @@ func New(opts ...InstOption) *Inst {
|
||||||
rootEC.root = rootEC
|
rootEC.root = rootEC
|
||||||
|
|
||||||
rootEC.addCmd("echo", invokableFunc(echoBuiltin))
|
rootEC.addCmd("echo", invokableFunc(echoBuiltin))
|
||||||
rootEC.addCmd("set", invokableFunc(setBuiltin))
|
|
||||||
rootEC.addCmd("set!", invokableFunc(mustSetBuiltin))
|
|
||||||
rootEC.addCmd("len", invokableFunc(lenBuiltin))
|
rootEC.addCmd("len", invokableFunc(lenBuiltin))
|
||||||
rootEC.addCmd("index", invokableFunc(indexBuiltin))
|
rootEC.addCmd("index", invokableFunc(indexBuiltin))
|
||||||
rootEC.addCmd("call", invokableFunc(callBuiltin))
|
rootEC.addCmd("call", invokableFunc(callBuiltin))
|
||||||
|
|
Loading…
Reference in a new issue