Skip to content

Physical units used in binary expressions fails with operands which aren't literals #1591

@kbirken

Description

@kbirken

The current unit language org.iets3.core.expr.typetags.physunits (see documentation) should support combining operands which have proper units using binary expressions, like plus, minus, etc. However, this fails if one of the operands is not a NumberLiteral, but a reference to some variable or a function call, even if the variable or function has the proper type and unit.

Example: Given the following definitions:

Image

Two literals can be combined, e.g. with a plus-expression (can be done also with other operators):

Image

But this fails if one of the operands isn't a literal, although the type including the physical unit or quantity matches:

Image

For function calls, the error looks even more weird:

Image

If the binary operation is a multiplication, the computed type is wrong (it contains two tags, one of them null):

Image

Expected: All these failing examples (and all similar ones) should work without any errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions