Skip to content

Incorrect Error Message in float64 Method in decode_number.go #352

@funplusxxx

Description

@funplusxxx

Hello,

I was going through the source code of msgpack and noticed a potential issue in the float64 method in the decode_number.go file.

Here is the code snippet:

func (d *Decoder) float64(c codes.Code) (float64, error) {
	switch c {
	case codes.Float:
		n, err := d.float32(c)
		if err != nil {
			return 0, err
		}
		return float64(n), nil
	case codes.Double:
		n, err := d.uint64()
		if err != nil {
			return 0, err
		}
		return math.Float64frombits(n), nil
	}

	n, err := d.int(c)
	if err != nil {
		return 0, fmt.Errorf("msgpack: invalid code=%x decoding float32", c)
	}
	return float64(n), nil
}


In the error message of the last fmt.Errorf, it says "decoding float32", but it should be "decoding float64" as the method is for decoding a float64 value.

The corrected error message should be:

return 0, fmt.Errorf("msgpack: invalid code=%x decoding float64", c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions