=== modified file 'rules/annotations/block_properties.rules'
--- old/rules/annotations/block_properties.rules	2025-04-07 08:20:02 +0000
+++ new/rules/annotations/block_properties.rules	2025-07-21 10:03:56 +0000
@@ -411,11 +411,13 @@
       </function>
       
       <function name="createLabel">
-         <parameter name="target"  type="com.goldencode.ast.Aast" />
-         <parameter name="blk"     type="com.goldencode.ast.Aast" />
-         <variable  name="lref"    type="com.goldencode.ast.Aast" />
-         <variable  name="nref"    type="com.goldencode.ast.Aast" />
-         <return    name="creat"   type="java.lang.Boolean" />
+         <parameter name="target"     type="com.goldencode.ast.Aast" />
+         <parameter name="blk"        type="com.goldencode.ast.Aast" />
+         <parameter name="isCatch"    type="java.lang.Boolean" />
+         <variable  name="lref"       type="com.goldencode.ast.Aast" />
+         <variable  name="nref"       type="com.goldencode.ast.Aast" />
+         <variable  name="label_text" type="java.lang.String" />
+         <return    name="creat"      type="java.lang.Boolean" />
          
          <rule>creat = false</rule>
          
@@ -424,23 +426,35 @@
             <!-- only inner blocks and editing blocks can be labeled -->
             <rule>
                blk.type == prog.inner_block  or
-               blk.type == prog.editing_block
-         
+               blk.type == prog.editing_block or
+               isCatch
+                        
                <!-- find the label definition -->
                <action>
                   lref = blk.getImmediateChild(prog.label_def, null)
                </action>
                
-               <rule>lref != null
+               <rule>isCatch
+                  <action>label_text = ""</action>
+                  <action on="false">label_text = lref.text</action>
+               </rule>
+               
+               <rule>lref != null or isCatch
                   <!-- create the label reference and the cross-ref to the
                        definition -->
                   <action>
                      nref = createProgressAst(prog.label,
-                                              lref.text,
+                                              label_text,
                                               target,
                                               0)
                   </action>
-                  <action>execLib("createXref", nref, lref.id)</action>
+                  
+                  <rule>lref != null                  
+	                 <action>execLib("createXref", nref, lref.id)</action>
+                  </rule>
+                  <rule>isCatch
+                     <action>nref.putAnnotation("localname", label_text)</action>
+                  </rule>
                   <action>creat = true</action>
                </rule>
             </rule>
@@ -1156,6 +1170,22 @@
          parent.type == prog.statement  and
          !descendant(prog.label, 1)
          
+         <variable name="action"      type="com.goldencode.ast.Aast" />
+         <variable name="actionLabel" type="com.goldencode.ast.Aast" />
+         <variable name="copyErr"     type="com.goldencode.ast.Aast" />
+         <variable name="isCatch"     type="java.lang.Boolean" />
+         
+         
+         <action>isCatch = false</action>
+         <rule>upPath(parent, prog.block)          and
+               upPath(parent.parent, prog.kw_catch)
+            <action>action = copy.firstChild</action>
+            
+            <rule>action != null and action.type != prog.label
+               <action>isCatch = true</action>
+            </rule>
+         </rule>
+         
          <!-- errBlock should never be null here, it should always be at
               least set to the external procedure, if this is set to a
               top-level block then no label will be created since such
@@ -1163,8 +1193,12 @@
               will be a label created -->
          <action>
             putNote("top_level_target",
-                    !evalLib("createLabel", copy, errBlock))
+                    !evalLib("createLabel", copy, errBlock, isCatch))
          </action>
+         
+         <rule>isCatch
+            <action>errBlock = copyErr</action>
+         </rule>
       </rule>
            
       <!-- ON phrase without an explicit target (label) for the UNDO must
@@ -1182,7 +1216,7 @@
          
          <!-- make the current block label explicit -->
          <action>
-            evalLib("createLabel", copy, copy.getAncestor(3))
+            evalLib("createLabel", copy, copy.getAncestor(3), false)
          </action>
       </rule>
       
@@ -1416,7 +1450,7 @@
             <action>copy.type = prog.kw_return</action>
             
             <!-- found a block target, create a label targeting the block -->
-            <action on="false">execLib("createLabel", copy, blockRef)</action>
+            <action on="false">execLib("createLabel", copy, blockRef, false)</action>
          </rule>
       
       </rule>
@@ -1434,7 +1468,7 @@
          <rule>nonDoBlock != null
             <!-- there is a non-DO block between this node and the nearest
                  top level block -->
-            <action>execLib("createLabel", copy, nonDoBlock)</action>
+            <action>execLib("createLabel", copy, nonDoBlock, false)</action>
             
             <!-- convert LEAVE to RETURN -->
             <action on="false">copy.type = prog.kw_return</action>

