diff --git a/internal/compiler/ir/optimize/inline.go b/internal/compiler/ir/optimize/inline.go index 9179d98..c5567d5 100644 --- a/internal/compiler/ir/optimize/inline.go +++ b/internal/compiler/ir/optimize/inline.go @@ -174,8 +174,8 @@ func (m *inlineMapper) transformArgs( return c } case 1: - if canImmediatelyPop(c) { - return immediatelyPop(c) + if res, ok := immediatelyPop(c); ok { + return res } fallthrough default: @@ -299,12 +299,14 @@ func argInstructionPred(i isa.Instruction) bool { } } -func canImmediatelyPop(c isa.Instructions) bool { - return len(c) > 0 && c[0] == isa.Arg.New(0) && !hasAnyArgInstruction(c[1:]) -} - -func immediatelyPop(c isa.Instructions) isa.Instructions { - return c[1:] +func immediatelyPop(c isa.Instructions) (isa.Instructions, bool) { + if len(c) != 0 || c[0] != isa.Arg.New(0) { + return nil, false + } + if res := c[1:]; !hasAnyArgInstruction(res) { + return res, true + } + return nil, false } func canMapArgsToLocals(c isa.Instructions, argc isa.Operand) bool { diff --git a/pkg/core/internal/params.go b/pkg/core/internal/params.go index 7fd7ca4..2a2e218 100644 --- a/pkg/core/internal/params.go +++ b/pkg/core/internal/params.go @@ -55,8 +55,8 @@ const ( // arguments provided doesn't match any of the declared parameter cases ErrUnmatchedCase = "got %d arguments, expected %s" - // ErrNoMatchingParamPattern is raised when none of the parameter patterns for - // a Lambda were capable of being matched + // ErrNoMatchingParamPattern is raised when none of the parameter patterns + // for a Lambda were capable of being matched ErrNoMatchingParamPattern = "no matching parameter pattern" ) diff --git a/pkg/core/source/10_sequences.ale b/pkg/core/source/10_sequences.ale index 52a9514..5a0c644 100644 --- a/pkg/core/source/10_sequences.ale +++ b/pkg/core/source/10_sequences.ale @@ -84,7 +84,7 @@ [r (rest coll)]) (last-inner r f)) prev))) - coll '())) + coll null)) (define-lambda fold-left [(func init coll) @@ -101,7 +101,7 @@ (define (reverse! coll) (if (reversible? coll) (reverse coll) - (fold-left conj '() coll))) + (fold-left conj null coll))) (define :private (swap-args func) (lambda (l r) (func r l))) diff --git a/pkg/core/source/14_exceptions.ale b/pkg/core/source/14_exceptions.ale index b17ccbe..e361387 100644 --- a/pkg/core/source/14_exceptions.ale +++ b/pkg/core/source/14_exceptions.ale @@ -32,7 +32,7 @@ (lambda-rec try-parse (clauses) (unless (seq? clauses) - {:block '() :catch '() :finally []} + {:block null :catch null :finally []} (let* ([f (first clauses)] [r (rest clauses)] [p (try-parse r)]) diff --git a/pkg/data/cons.go b/pkg/data/cons.go index 1ef1755..02580df 100644 --- a/pkg/data/cons.go +++ b/pkg/data/cons.go @@ -19,8 +19,8 @@ type ( // Pairs represents multiple pairs Pairs []Pair - // Cons cells are the standard implementation of a Pair. Unlike - // other Pairs (ex: List, Vector), it is not treated as a Sequence + // Cons cells are the standard implementation of a Pair. Unlike other Pairs + // (ex: List, Vector), it is not treated as a Sequence Cons struct { car Value cdr Value diff --git a/pkg/ffi/wrap.go b/pkg/ffi/wrap.go index e38d8a5..8564f02 100644 --- a/pkg/ffi/wrap.go +++ b/pkg/ffi/wrap.go @@ -60,8 +60,8 @@ func WrapType(t reflect.Type) (Wrapper, error) { s := new(struct{ Wrapper }) cache.put(t, s) - // register the final Wrapper, and wire it into the stub for those - // Wrappers that may refer to it + // register the final Wrapper, and wire it into the stub for those Wrappers + // that may refer to it w, err := makeWrappedType(t) if err != nil { return nil, err