Skip to content

interp: mis-interpretation of global map initializer #4505

Open
@eliasnaur

Description

@eliasnaur
$ cat precomp.go
package main

import (
	"crypto/sha256"
	"fmt"
	"os"
)

var (
	tag       = sha256.Sum256(nil)
	globalMap = map[string][32]byte{
		"": tag,
	}
)

func main() {
	localMap := map[string][32]byte{
		"": tag,
	}
	if localMap[""] != globalMap[""] {
		fmt.Printf("global %.32x\nlocal %.32x\n", globalMap, localMap)
		os.Exit(1)
	}
}
$ go run precomp.go
$ tinygo run precomp.go
global map[:0000000000000000000000000000000000000000000000000000000000000000]
local map[:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]
failed to run compiled binary /tmp/nix-shell.HWhNg6/tinygo1488071277/main: exit status 1

This breaks anything relying on https://github.com/btcsuite/btcd/blob/67b8efd3ba53b60ff0eba5d79babe2c3d82f6c54/chaincfg/chainhash/hash.go#L50.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcore

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions