Commit f4c5c661 authored by Stefan Behnel's avatar Stefan Behnel

Show an error message instead of crashing when no C++ constructor is declared.

Closes #1791.
parent e79f2cd3
...@@ -5157,6 +5157,10 @@ class CallNode(ExprNode): ...@@ -5157,6 +5157,10 @@ class CallNode(ExprNode):
elif type and type.is_cpp_class: elif type and type.is_cpp_class:
self.args = [ arg.analyse_types(env) for arg in self.args ] self.args = [ arg.analyse_types(env) for arg in self.args ]
constructor = type.scope.lookup("<init>") constructor = type.scope.lookup("<init>")
if not constructor:
error(self.function.pos, "no constructor found for C++ type '%s'" % self.function.name)
self.type = error_type
return self
self.function = RawCNameExprNode(self.function.pos, constructor.type) self.function = RawCNameExprNode(self.function.pos, constructor.type)
self.function.entry = constructor self.function.entry = constructor
self.function.set_cname(type.empty_declaration_code()) self.function.set_cname(type.empty_declaration_code())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment