Skip to content

Fix operator precedence in EXPRESS aggregate initializer repetition - #9458

Open
gostak-dd wants to merge 1 commit into
IfcOpenShell:v0.9.0from
gostak-dd:fix-aggregate-initializer-precedence
Open

gostak-dd wants to merge 1 commit into
IfcOpenShell:v0.9.0from
gostak-dd:fix-aggregate-initializer-precedence

Conversation

@gostak-dd

Copy link
Copy Markdown

Fixes the TypeError: unsupported operand type(s) for -: 'list' and 'int' reported in buildingSMART/validate#266 (buildingSMART/validate#266).

The rule compiler emitted [expr] * count without parenthesizing the count expression, so IfcMakeArrayOfArray's generated

res = [IfcListToArray(...)] * u1 - low1 + 1

evaluated as ([...] * u1) - low1, raising a TypeError. This broke the Weights derived attribute on IfcRationalBSplineSurfaceWithKnots, making the IfcSurfaceWeightsPositive where rule fail on valid files.

Changes:

  • rule_compiler.py: aggregate initializer template now emits ([expr] * (count))
  • All generated express/rules/IFC*.py files patched accordingly (11 files with IfcMakeArrayOfArray)

Verified by running the patched IfcMakeArrayOfArray on the weights array from the issue's #97=IfcRationalBSplineSurfaceWithKnots instance: no TypeError, and IfcSurfaceWeightsPositive passes as expected.

The rule compiler emitted '[expr] * count' without parenthesizing the
count expression, so IfcMakeArrayOfArray's
'[...] * u1 - low1 + 1' evaluated as '([...] * u1) - low1', raising
TypeError: unsupported operand type(s) for -: 'list' and 'int'.

This broke the Weights derived attribute on
IfcRationalBSplineSurfaceWithKnots and made the
IfcSurfaceWeightsPositive where rule fail on valid files
(buildingSMART/validate#266).

Fix the template in rule_compiler.py and patch the generated
rules files accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant