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

Type alias getting "DeclarationTypeChanged" #22

Open
jpillora opened this issue Jul 17, 2020 · 5 comments
Open

Type alias getting "DeclarationTypeChanged" #22

jpillora opened this issue Jul 17, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@jpillora
Copy link

jpillora commented Jul 17, 2020

While technically true, Declaration Type did Change. It's a compatible change. Is this expected behaviour:

jpillora/gocompat@e9400c2

"github.com/jpillora/gocompat".Add DeclarationTypeChanged
"github.com/jpillora/gocompat".Num DeclarationTypeChanged
found backwards incompatible changes
@jpillora
Copy link
Author

Maybe there's compatibility issues from going from func to var? However the type alias should be fine right? My understanding is the purpose of type aliases was to perform exactly this kind of change

@smola
Copy link
Owner

smola commented Jul 19, 2020

@jpillora This is currently the expected behavior. Changing an existing type to an alias is not backwards compatible. For example:

  • Reflection: reflect.TypeOf on Num would return gocompat.Num before the change, but it will be newmath.Num after it.
  • Equality: Before the change, gocompat.Num and newmath.Num values would not be equal. After the change, they are. This can break code that was previously dealing with both types and is particularly relevant if they come from different modules.

That being said, I think it would make sense to have more fine-grained output here and signaling when the only change in the declaration is the presence of an alias or the change of an alias target.

@jpillora
Copy link
Author

RE: Reflection: true - though this is a runtime compatibility issue, similar to introducing a logical error

RE: Equality: before the change newmath didn't exist. Are you refering to a case where newmath.Num existed, but referred to a different type?

@jpillora
Copy link
Author

Basically, what I'm looking for is "will old programs compile with these changes?" and then any runtime issues can be resolved after that

@smola smola added the enhancement New feature or request label Jul 21, 2020
@smola
Copy link
Owner

smola commented Jul 21, 2020

Equality: before the change newmath didn't exist.

Yep. I'll check if there is a reasonable way to check that. It can probably done if both types belong to the same module.

Basically, what I'm looking for is "will old programs compile with these changes?"

Ok. Sounds reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants