diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 379440177..48cd70fef 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -1833,7 +1833,15 @@ namespace PascalABCCompiler.NETGenerator if (attrs[i].qualifier == SemanticTree.attribute_qualifier_kind.return_kind) { var constr = (attrs[i].AttributeConstructor is ICompiledConstructorNode) ? (attrs[i].AttributeConstructor as ICompiledConstructorNode).constructor_info : helper.GetConstructor(attrs[i].AttributeConstructor).cnstr; - mb.SetMarshal(UnmanagedMarshal.DefineUnmanagedMarshal((UnmanagedType)attrs[i].Arguments[0].value)); + + try + { + mb.SetMarshal(UnmanagedMarshal.DefineUnmanagedMarshal((UnmanagedType)attrs[i].Arguments[0].value)); + } + catch(ArgumentException ex) + { + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace(", переданный для DefineUnmanagedMarshal,",""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); + } } else mb.SetCustomAttribute(cab); diff --git a/TestSuite/errors/err0345_marshal.pas b/TestSuite/errors/err0345_marshal.pas new file mode 100644 index 000000000..a819a15b0 --- /dev/null +++ b/TestSuite/errors/err0345_marshal.pas @@ -0,0 +1,6 @@ +program err0345_marshal; +[Result: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.SafeArray)] +function f1: array of byte; +external 'any.dll'; + +begin end. \ No newline at end of file