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

Validation: Invalid Function return types #273

Closed
riederm opened this issue Aug 31, 2021 · 3 comments · Fixed by #329
Closed

Validation: Invalid Function return types #273

riederm opened this issue Aug 31, 2021 · 3 comments · Fixed by #329
Assignees
Labels
bug Something isn't working good first issue Good for newcomers validation candidate for syntactic or semantic validation
Projects

Comments

@riederm
Copy link
Collaborator

riederm commented Aug 31, 2021

As far as the parser is concerned, a Function can return (and define!!) a lot of different types - but not everything makes sense:

valid return types:

  • Array-Types (ARRAY[0..3] OF INT, ...)
  • Pointer-Types (POINTER TO INT, ...)
  • String-Types (STRING[23], WSTRING[100], ...)
  • Scalar Types (INT, BOOL, etc.)

invalid return types:

  • Struct-Types ... cannot be assigned because the type is unknown by any caller
FUNCTION foo : STRUCT x : INT; y : INT; END_STRUCT
 ... 
END_FUNCTION
  • Enum-Type ... cannot be assigned because the type is unknown by any caller
FUNCTION foo : (green, yellow, red)
 ... 
END_FUNCTION
  • VarArgs ... makes no sense

unclear ...

  • SubRangeType ... maybe useful ... but will this be enforced by the compiler? i guess not?
@riederm riederm added bug Something isn't working validation candidate for syntactic or semantic validation labels Aug 31, 2021
@ghaith
Copy link
Collaborator

ghaith commented Sep 1, 2021

I assume the assignment of Subrange will be validated using the CHECK_XX method as every other variable. Not sure what else we could enforce there.

@riederm
Copy link
Collaborator Author

riederm commented Sep 1, 2021

I assume the assignment of Subrange will be validated using the CHECK_XX method as every other variable. Not sure what else we could enforce there.

Good point ... So it could make sense to be used as a functions return

@riederm riederm added the good first issue Good for newcomers label Sep 30, 2021
@99NIMI 99NIMI added this to To do in Next via automation Sep 30, 2021
@99NIMI 99NIMI self-assigned this Oct 12, 2021
@create-issue-branch
Copy link

@99NIMI 99NIMI moved this from To do to In progress in Next Oct 12, 2021
@99NIMI 99NIMI linked a pull request Oct 13, 2021 that will close this issue
@99NIMI 99NIMI moved this from In progress to Review in progress in Next Oct 13, 2021
Next automation moved this from Review in progress to Done Oct 18, 2021
99NIMI added a commit that referenced this issue Oct 18, 2021
…nction_return_types

added validation for function return types (#273)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers validation candidate for syntactic or semantic validation
Projects
Status: Done
Next
Done
Development

Successfully merging a pull request may close this issue.

3 participants