Opened 13 years ago

Closed 8 years ago

#2365 closed defect (fixed)

Record constructor does not set dependent parameters

Reported by: c.schulze@… Owned by: Per Östlund
Priority: high Milestone: 2.0.0
Component: New Instantiation Version: 1.9.0Beta
Keywords: Cc:

Description (last modified by Martin Sjölund)

model emptyVector1
  record R
    parameter Integer i = 2;
    parameter Real x[i]=zeros(i);
  end R;
  R r = R(i = 0);
end emptyVector1;

The call to the record constructor should enable the definition of r. But here the size of r.x is [2] and in the constructor [0]. -> incompatible sizes... (OMC r15030)

Change History (15)

comment:1 by Martin Sjölund, 13 years ago

Component: Backend → Frontend
Description: modified (diff)
Owner: changed from probably noone to somebody

comment:2 by Martin Sjölund, 13 years ago

Summary: Record cannot be set by constructor due to incompatible vector sizes → Record constructor does not set dependent parameters

The workaround is (as usual), to not use the record constructor, but rather just modify the record. OMC is a little stupid sometimes.

R r(i=0);

I have not looked closer into the specification. It might be that you should not be able to do this. But from what I have remember, default arguments to functions should be handled specially; and not the way OMC does, i.e. no binding uses a different execution path from with binding.

comment:3 by Martin Sjölund, 13 years ago

Milestone: 1.9.0 → 1.9.1

Postponed until 1.9.1

comment:4 by Martin Sjölund, 12 years ago

Milestone: 1.9.1 → 1.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:5 by Martin Sjölund, 12 years ago

Milestone: 1.9.2 → 1.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:6 by Martin Sjölund, 11 years ago

Milestone: 1.9.3 → 1.9.4

Moved to new milestone 1.9.4

comment:7 by Adrian Pop, 11 years ago

Owner: changed from somebody to Adrian Pop
Status: new → accepted

comment:8 by Martin Sjölund, 11 years ago

Milestone: 1.9.4 → 1.9.5

Milestone pushed to 1.9.5

comment:9 by Martin Sjölund, 11 years ago

Milestone: 1.9.5 → 1.10.0

Milestone renamed

comment:10 by Francesco Casella, 10 years ago

Milestone: 1.10.0 → 2.0.0

comment:11 by Francesco Casella, 8 years ago

Component: Frontend → New Instantiation
Owner: changed from Adrian Pop to Per Östlund
Priority: blocker → high
Status: accepted → assigned

As of v1.13.0-dev-672-g87286cb84, the result with the NF is

[1] 00:05:31 Translation Error
[OMCompiler/Compiler/NFFrontEnd/NFRangeIterator.mo: 212:11-213:61]:
Internal error NFRangeIterator.hasNext got invalid range R.i

I don't see this as a critical bug, so I am removing the blocker status. If this affects any existing library, feel free to make it a blocker for 2.0.0 again.

comment:12 by Francesco Casella, 8 years ago

Milestone: 2.0.0 → 2.1.0

The NF now reports:

[emptyVector1: 4:5-4:33]: Could not evaluate structural parameter (or constant): r.i 
which gives dimensions of array: x. 
Array dimensions must be known at compile time.

which is a bit odd, as i is obviously as structural parameter. For some reason, it is not recognized as such.

As this issue is most likely not affecting the library coverage, I am postponing it to 2.1.0

in reply to:  12 comment:13 by Per Östlund, 8 years ago

Replying to casella:

As this issue is most likely not affecting the library coverage, I am postponing it to 2.1.0

I'm fairly certain it does affect library coverage. There's some similar issues in some libraries (I think BuildingSystems, I don't remember exactly), where the size of a record field depends on another record field. But I don't think it affects the MSL.

comment:14 by Francesco Casella, 8 years ago

Milestone: 2.1.0 → 2.0.0

OK. I've set it back to 2.0.0

comment:15 by Francesco Casella, 8 years ago

Resolution: → fixed
Status: assigned → closed

Works with -d=newInst using omc v1.14.0-dev-105-g2de3e7582

Note: See TracTickets for help on using tickets.