Skip to content

maps cannot contain multiple NaN's #3867

@thehowl

Description

@thehowl

This is behaviour that also surprised me about Go that I did not know about, but apparently, because NaN != NaN, then you can have multiple NaN's as keys in a single map.

In Gno, this leads to a panic due to having duplicate keys.

package main

import (
	"fmt"
	"math"
)

var NaN = math.NaN()

func main() {
	fmt.Println(map[float64]int{NaN: 1, NaN: 2})
}

Metadata

Metadata

Labels

🐞 bugSomething isn't working

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions