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

ast: improve error message when inheritance is used without ref #3570

Conversation

simonvonhackewitz
Copy link
Contributor

fix #3563

How it looks now

> cat /tmp/impr_err_msg.fz
parent is
  func String => abstract

child : parent is
  redef func => "not working because ref keyword missing"


main(x parent) =>
  say (x.func)

main child
> FUZION_DISABLE_ANSI_ESCAPES=true fz /tmp/impr_err_msg.fz

/tmp/impr_err_msg.fz:11:6: error 1: Incompatible types when passing argument in a call
main child
-----^^^^^
Actual type for argument #1 'x' does not match expected type.
In call to          : 'main'
expected formal type: 'parent'
actual type found   : 'child'
assignable to       : 'child'
for value assigned  : 'child'
To solve this you could:
  • make  'parent' a reference by adding the 'ref' keyword, so all its heirs can be used in place of it
  • change the type of the target 'x' to 'child'
  • convert the type of the assigned value to 'parent'.

one error.

@michaellilltokiwa michaellilltokiwa merged commit 68f84bd into tokiwa-software:main Aug 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve "incompatible types" error message when inheritance with missing ref keyword is used
3 participants