Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitmask enums conversion from string #90

Closed
mdm13 opened this issue Nov 28, 2023 · 2 comments · Fixed by #91
Closed

Bitmask enums conversion from string #90

mdm13 opened this issue Nov 28, 2023 · 2 comments · Fixed by #91
Labels
bug Something isn't working

Comments

@mdm13
Copy link

mdm13 commented Nov 28, 2023

The unmarshaling of bitmask enum seems to be incomplete: for example in the case of common.POSITION_TARGET_TYPEMASK

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (e *POSITION_TARGET_TYPEMASK) UnmarshalText(text []byte) error {
	labels := strings.Split(string(text), " | ")
	var mask POSITION_TARGET_TYPEMASK
	for _, label := range labels {
		if value, ok := values_POSITION_TARGET_TYPEMASK[label]; ok {
			mask |= value
		} else if value, err := strconv.Atoi(label); err == nil {
			mask |= POSITION_TARGET_TYPEMASK(value)
		} else {
			return fmt.Errorf("invalid label '%s'", label)
		}
	}
        //missing statement here:
        //       *e=mask
	return nil
}

the statement *e=mask before return nil is missing. Without this statement there is no conversion from string. The correction should be reported in conversion.go.

@aler9
Copy link
Member

aler9 commented Dec 16, 2023

Thanks for reporting the issue, this is fixed by #91, i also added tests so this can't happen anymore.

Copy link

This issue is being locked automatically because it has been closed for more than 6 months.
Please open a new issue in case you encounter a similar problem.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants