Opened 13 years ago
Closed 12 years ago
#1707 closed defect (fixed)
type mismatch
Reported by: | mohamed | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9.0 |
Component: | Frontend | Version: | |
Keywords: | Cc: | mohamed |
Description (last modified by )
Have you any idea how can I solve this problem,
model tableau String tab[8]; equation tab=getVariableNameTable(2,8); end tableau; function getVariableNameTable extends modelInExpressionBase; public input Integer indexModel ; input Integer dim; output String variableNameTable[dim] ; algorithm if indexModel == 1 then // model1 variableNameTable[1:size(model2,1)] := model1[:]; elseif indexModel == 2 then // model2 variableNameTable [1:size(model2,1)]:= model2[:]; end if; end getVariableNameTable; record modelInExpressionBase public final constant String model1[8] = {"a", "b", "c", "d", "e", "f", "g","h"}; final constant String model2[8] = {"a", "b", "c", "d", "e", "f", "g", "i"}; end modelInExpressionBase;
Error: Type mismatch in assignment in variableNameTable[{1,2,3,4,5,6,7,8}] := {\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\"} of String[dim] := String[8] Error: Error occurred while flattening model tableau
Thank you in advance,
Best regards,
Change History (6)
comment:2 by , 13 years ago
Using the function I posted below now works properly (r11265). It type-checks and compiles fine.
comment:3 by , 12 years ago
Cc: | mohamed, → mohamed |
---|---|
Component: | → Backend |
Description: | modified (diff) |
Milestone: | → 1.9.0 |
comment:4 by , 12 years ago
Component: | Backend → Frontend |
---|
comment:5 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
The initial code now works in r12755. Regression testing in SpliceUnknownDest.mo.
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Note that a function may not extend from a record (see 7.1.3 in https://modelica.org/documents/ModelicaSpec32Revision1.pdf), and that the constants have to be protected.
Does work (except code generation needs to be fixed)