Skip to content

Commit 3c56c86

Browse files
committed
Merge branch 'master' into display_image
2 parents e7a9663 + 720be35 commit 3c56c86

File tree

538 files changed

+81312
-44483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

538 files changed

+81312
-44483
lines changed

gophernotes

34.2 MB
Binary file not shown.

kernel.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ func doEval(ir *interp.Interp, code string) (val []interface{}, err error) {
425425
// Check if the last node is an expression. If the last node is not an expression then nothing
426426
// is returned as a value. For example evaluating a function declaration shouldn't return a value but
427427
// just have the side effect of declaring the function.
428+
//
429+
// This is actually needed only for gomacro classic interpreter
430+
// (the fast interpreter already returns values only for expressions)
431+
// but retained for compatibility.
428432
var srcEndsWithExpr bool
429433
if len(nodes) > 0 {
430434
_, srcEndsWithExpr = nodes[len(nodes)-1].(ast.Expr)
@@ -434,34 +438,26 @@ func doEval(ir *interp.Interp, code string) (val []interface{}, err error) {
434438
compiledSrc := ir.CompileAst(srcAst)
435439

436440
// Evaluate the code.
437-
result, results := ir.RunExpr(compiledSrc)
441+
results, _ := ir.RunExpr(compiledSrc)
438442

439443
// If the source ends with an expression, then the result of the execution is the value of the expression. In the
440444
// event that all return values are nil, the result is also nil.
441445
if srcEndsWithExpr {
442-
// `len(results) == 0` implies a single result stored in `result`.
443-
if len(results) == 0 {
444-
if val := base.ValueInterface(result); val != nil {
445-
return []interface{}{val}, nil
446-
}
447-
return nil, nil
448-
}
449446

450447
// Count the number of non-nil values in the output. If they are all nil then the output is skipped.
451448
nonNilCount := 0
452-
var values []interface{}
453-
for _, result := range results {
449+
values := make([]interface{}, len(results))
450+
for i, result := range results {
454451
val := base.ValueInterface(result)
455452
if val != nil {
456453
nonNilCount++
457454
}
458-
values = append(values, val)
455+
values[i] = val
459456
}
460457

461458
if nonNilCount > 0 {
462459
return values, nil
463460
}
464-
return nil, nil
465461
}
466462

467463
return nil, nil

vendor/github.com/cosmos72/gomacro/.gitignore

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)