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

Simple function returning a value cannot be compiled - wrong uses: 1 1 or Compilation failed... #6014

Open
martinwork opened this issue Nov 20, 2024 · 0 comments

Comments

@martinwork
Copy link
Contributor

Describe the bug

Arising from support ticket https://support.microbit.org/helpdesk/tickets/83988 (private)

This example cannot be compiled - shows “wrong uses: 1 1”
Image

It fails in earlier MakeCode versions back to v3 with "Compilation failed, please check your code for errors"

This project was created in v7
https://makecode.microbit.org/_b5440xhxoC9j

This project was created in v3.
https://makecode.microbit.org/_7RLdkpXdLfJL

From the ticket...

If the function is called with a constant, e,g, call to test(2), then no issue.
If the function is modified to return the input value, no issue arises.
If the function is changed to return the cube of a number by the same, chained multiplication of the input number, no error results.
The math functions “+” and “-“ are not affected by this, however “*”. “/” & “**” are.
A work round is to introduce a temporary variable to hold the result of the calculation and return that.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://makecode.microbit.org/_b5440xhxoC9j
  2. Click on Download or Save
  3. See error

Expected behavior
Compilation succeeds

micro:bit version (please complete the following information):
not hardware related

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22]
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

No branches or pull requests

1 participant