microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
727 stars 638 forks source link

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

Open martinwork opened 5 days ago

martinwork commented 5 days ago

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):