Skip to content

TYPE-only assignment fails silently on type conflict. #187

@python-processing-unit

Description

@python-processing-unit

According to the specification section 3.2:

A symbol MAY be declared without a value using TYPE name. Such a declaration records the symbol's static type but does not create a readable runtime binding until an assignment occurs. The type and name MUST be separated by one or more space characters, and no other character MAY appear between them.

And the specification section 1:

Prefix is a statically typed, imperative, interpreted programming language focused on explicit, readable source code.

In the implementation, however, attempting to specify a symbol's type without assigning a value does nothing if that type conflicts the existing static type for that symbol, rather than erroring.

Example:

Prefix REPL. Enter statements, blank line to run buffer.
>>> INT n = 0d1
>>> PRINT(TYPE(n))
INT
>>> BOOL n
>>> PRINT(TYPE(n))
INT
>>> n = TRUE
Traceback (most recent call last):
  File "<repl>", line 1, in <top-level>
    n = TRUE
    State log index: 4  State id: s_000004
RuntimeError: Type mismatch: expected INT but got BOOL (rewrite: ASSIGN)

Update the implementation, and add a regression test.

Metadata

Metadata

Labels

bugSomething isn't workinginterpreterRequires a code change in the interpreter.patchRequires a patch version change.testSomething related to the test suite.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions