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

NO compiler error when misusing ENUMs #75

Closed
cpyrgas opened this issue Jun 19, 2019 · 2 comments
Closed

NO compiler error when misusing ENUMs #75

cpyrgas opened this issue Jun 19, 2019 · 2 comments
Assignees
Milestone

Comments

@cpyrgas
Copy link

cpyrgas commented Jun 19, 2019

The code below assigns a value of Enum2 to a local of Enum1, causing unexpected runtime results. Instead, an error should be reported. Similar issue exists for passing ENUMs of different type to method params etc.

ENUM Enum1
	MEMBER m1
	MEMBER m2
END ENUM
ENUM Enum2
	MEMBER m2
	MEMBER m1
END ENUM

FUNCTION Start() AS VOID
	LOCAL e AS Enum1
	e := Enum2.m1
	? e:ToString() // m2
RETURN
@RobertvanderHulst
Copy link
Member

Vulcan allowed to "silently" (Implicitely) convert Integer values to enums and also do Add and Subtract operations on enums.
We have added similar functionality to the compiler. I think this is a side effect of this.
I would not mind removing the implicit conversions from int to enum and back and I am almost sure that this will then also be fixed.
Explicit casts between Int and Enum will always work.

@cpyrgas
Copy link
Author

cpyrgas commented Jun 19, 2019

Yes, those implicit conversions can be handly, but are also very dangerous. Indeed the same problem existed in vulcan as well. I suggest we do it in RC3, before the final release and see the responses. I will take care of explaining in details why this HAD to be done.

@RobertvanderHulst RobertvanderHulst added this to the 2.0 Release milestone Jun 27, 2019
@RobertvanderHulst RobertvanderHulst self-assigned this Jul 14, 2021
RobertvanderHulst pushed a commit that referenced this issue Dec 4, 2024
Simultaneous update of Simplified Chinese documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants