const() not behaving per documentation

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
dbc
Posts: 89
Joined: Fri Aug 28, 2015 11:02 pm
Location: Sunnyvale, CA

const() not behaving per documentation

Post by dbc » Mon Jul 24, 2017 3:33 am

Code: Select all

MicroPython v1.9.1 on 2017-06-11; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> x = const(1)
>>> y = const(1<<2)
>>> z = const(x+1)
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: constant must be an integer
>>> z = const(int('1'))
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: constant must be an integer
>>> 
x & y match documentation.

Doc says:
It can even include other const symbols that have already been defined, e.g. 1 << BIT.
so I would expect z=const(x+1) to work.

Should I expect z=const(int('1)) to work?

User avatar
dbc
Posts: 89
Joined: Fri Aug 28, 2015 11:02 pm
Location: Sunnyvale, CA

Re: const() not behaving per documentation

Post by dbc » Mon Jul 24, 2017 4:23 am

Tried the test micropyton/test/micropython/const.py on my pyboard and it fails.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: const() not behaving per documentation

Post by pythoncoder » Mon Jul 24, 2017 5:34 am

I think you've found a bug.
Peter Hinch
Index to my micropython libraries.

Post Reply