Skip to content

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

Closed
microsoft/pxt
#10553
@martinwork

Description

@martinwork

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]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions