﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5623	Import issue in OpenModelica	Christian Kral <dr.christian.kral@…>	somebody	"Please consider the following package:

{{{
package ImportIssue
  model Example
    import ImportIssue.Intermediate.MyType;
    MyType var;
  equation
    var = {0,1,2,3};
  end Example;

  package Types
    type MyType = Real[4];
  end Types;

  package Intermediate
    import ImportIssue.Types.MyType;
  end Intermediate;
end ImportIssue;
}}}

The simulation example `ImportIssue.Example` demonstrates a detour of imports in Modelica:

In the package {{{Intermediate}}} the import of {{{MyType}}} is made. The example now imports {{{ImportIssue.Intermediate.MyType}}} and I am not sure if this is legal Modelica. However, if I check {{{ImportIssue.Example}}} OpenModelica reports:

{{{
Check of ImportIssue.Example completed successfully.
Class ImportIssue.Example has 4 equation(s) and 4 variable(s).
4 of these are trivial equation(s).
}}}

If I simulate the example, it terminates successfully.

If I check the example in Dymola, the following error occurs:


{{{
Check of ImportIssue.Example:

Error: Lookup failed for import ImportIssue.Intermediate.MyType
Near file: /home/data/work/ImportIssue.mo, line 2
Context: ImportIssue.Example

Error: Lookup failed for import ImportIssue.Intermediate.MyType
Near file: /home/data/work/ImportIssue.mo, line 2
Context: ImportIssue.Example

Component type specifier MyType not found
File: /home/data/work/ImportIssue.mo, line 5
Component context: var
Component declared as MyType var in ImportIssue.Example

ERRORS have been issued.
}}}

When compiling the example in JModelica, the following error message is caused:

{{{
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""/home/christian/bin/jmodelica20190827/Python/pymodelica/compiler.py"", line 146, in compile_fmu
    separate_process, jvm_args)       
  File ""/home/christian/bin/jmodelica20190827/Python/pymodelica/compiler.py"", line 251, in _compile_unit
    return comp.compile_Unit(class_name, file_name, target, version, compile_to)
  File ""/home/christian/bin/jmodelica20190827/Python/pymodelica/compiler_wrappers.py"", line 364, in compile_Unit
    self._handle_exception(ex)
  File ""/home/christian/bin/jmodelica20190827/Python/pymodelica/compiler_wrappers.py"", line 544, in _handle_exception
    raise CompilerError(errors, warnings)
pymodelica.compiler_exceptions.CompilerError: 
2 error(s) and 0 warning(s) found:

Error at line 3, column 37, in file 'ImportIssue.mo':
  Cannot find class or component declaration for MyType

Error at line 5, column 7, in file 'ImportIssue.mo':
  Cannot find class declaration for MyType
}}}

"	defect	closed	high	1.14.0	*unknown*	v1.14.0-dev-nightly	fixed		georg.vorlaufer@… Per Östlund
