can't unmarshal "" to *string field

Bug #1132537 reported by William Reade
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
goyaml
Fix Released
Undecided
Gustavo Niemeyer
juju-core
Fix Released
Medium
Данило Шеган

Bug Description

In the following program, I would expect "yay" to be printed rather than "whoops" (or nothing).

------------------------------------------------
package main

import "launchpad.net/goyaml"

func main() {
    var v struct{ Hello *string }
    if err := goyaml.Unmarshal([]byte(`hello: ""`), &v); err != nil {
        panic(err)
    }
    if v.Hello == nil {
        print("whoops")
    } else if *v.Hello == "" {
        print("yay")
    }
}

Related branches

Changed in goyaml:
assignee: nobody → Данило Шеган (danilo)
status: New → In Progress
Revision history for this message
Данило Шеган (danilo) wrote :

I've verified that lp:goyaml r39 (fix for #1133337) fixes this as well. I'll be removing the test as it itself suggests and emailing the juju-dev list to remind everyone that they need to up the version of goyaml.

Changed in goyaml:
assignee: Данило Шеган (danilo) → Gustavo Niemeyer (niemeyer)
status: In Progress → Fix Committed
Changed in juju-core:
assignee: nobody → Данило Шеган (danilo)
status: New → In Progress
Changed in juju-core:
milestone: none → 2.0
Changed in goyaml:
status: Fix Committed → Fix Released
Changed in juju-core:
status: In Progress → Fix Committed
Changed in juju-core:
importance: Undecided → Medium
Martin Packman (gz)
Changed in juju-core:
milestone: 2.0 → 1.10.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.