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

Documentation: type promotion #6251

Closed
donaldcallen opened this issue Aug 29, 2020 · 1 comment · Fixed by #9433
Closed

Documentation: type promotion #6251

donaldcallen opened this issue Aug 29, 2020 · 1 comment · Fixed by #9433
Labels
Unit: Documentation Bugs/feature requests, that are related to the documentations.

Comments

@donaldcallen
Copy link

donaldcallen commented Aug 29, 2020

I just started looking at V, reading the documentation and found what I think are problems.

In the section 'Primitive types', in the discussion of types that can be automatically promoted or coerced to other types, there is a diagram. In that diagram, there is an arrow from int to f32, indicating that an int can be promoted to an f32. But the immediately following discussion rightly disallows this because of loss of precision. I think the diagram should not have an arrow from int to f32.

That section also says "A small primitive type on one side can be automatically promoted if it fits completely into the data range of the type on the other side.". That is necessary but not sufficient, which the wording seems to imply. The promotion must also not cause loss of precision.

@ntrel ntrel changed the title Documentation problems Documentation: type promotion Aug 29, 2020
@casperbrike
Copy link
Contributor

I was confused by this section of documentation as well. This piece of code is complied with no errors (despite precision loss):

a := 2147483647
b := f32(1)

println(a + b)

Looks like the diagram reflects real state of things but the documentation is misleading. On the other side if type promotion should preserve precision then we have a bug in the behavior and the diagram deceives us.

My env:
V: 0.1.29 914c1a5
OS: Manjaro Linux 20.1

@hex2f hex2f added the Unit: Documentation Bugs/feature requests, that are related to the documentations. label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: Documentation Bugs/feature requests, that are related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants