diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index aa181479c96824820c7eec28c79565cc9296a425..27b188442e872e05e8d8458e80989b63743cb091 100644
--- a/compiler2/ttcn3/AST_ttcn3.cc
+++ b/compiler2/ttcn3/AST_ttcn3.cc
@@ -6567,7 +6567,7 @@ namespace Ttcn {
               error("Only `prototype(convert)' is allowed for %s encoding functions",
                 Type::get_encoding_name(encoding_type));
             }
-            else {
+            else if (input_type->is_ref()) {
               // let the input type know that this is its encoding function
               input_type->get_type_refd()->set_coding_function(true, this);
               // treat this as a manual external function during code generation
@@ -6689,7 +6689,7 @@ namespace Ttcn {
             error("Only `prototype(sliding)' is allowed for %s decoding functions",
               Type::get_encoding_name(encoding_type));
           }
-          else if (output_type) {
+          else if (output_type != NULL && output_type->is_ref()) {
             // let the output type know that this is its decoding function
             output_type->get_type_refd()->set_coding_function(false, this);
             // treat this as a manual external function during code generation
diff --git a/function_test/Semantic_Analyser/encode/encode_asn_SE.ttcn b/function_test/Semantic_Analyser/encode/encode_asn_SE.ttcn
index ad675829bf74878bdb76d237fe8d8575cca76afd..b084dc88107924a7e703ba2ca4543026a13430e3 100644
--- a/function_test/Semantic_Analyser/encode/encode_asn_SE.ttcn
+++ b/function_test/Semantic_Analyser/encode/encode_asn_SE.ttcn
@@ -122,5 +122,18 @@ external function f_enc_choice1(in Choice x) return bitstring
   
 external function f_enc_choice2(in Choice x) return bitstring
   with { extension "prototype(convert) encode(PER)" }
+  
+/* external function declarations for nonexistent types */
+external function f_enc_non1(in NonExistent x) return bitstring //^In external function definition// //^In formal parameter list// //^In parameter// //There is no local or imported definition with name//
+  with { extension "prototype(convert) encode(JSON)" }
+  
+external function f_enc_non2(in NonExistent x) return bitstring //^In external function definition// //^In formal parameter list//  //^In parameter// //There is no local or imported definition with name//
+  with { extension "prototype(convert) encode(PER)" }
+  
+external function f_dec_non1(inout bitstring x, out NonExistent y) return integer //^In external function definition// //^In formal parameter list//  //^In parameter// //There is no local or imported definition with name//
+  with { extension "prototype(sliding) decode(BER)" }
+
+external function f_dec_non2(inout bitstring x, out NonExistent y) return integer //^In external function definition// //^In formal parameter list//  //^In parameter// //There is no local or imported definition with name//
+  with { extension "prototype(sliding) decode(PER)" }
 
 }