         for port in context.ports
           ipClone = context.closeIp.clone()
           @addToResult result, port, ipClone, false
-          @getBracketContext('out', port, ipClone.scope, ipClone.index).pop()
+          @getBracketContext('out', port, ipClone.scope).pop()
 
     delete result.__bracketClosingBefore
     delete result.__bracketContext


  getBracketContext: (type, port, scope, idx) ->
    {name, index} = ports.normalizePortName port
    portsList = if type is 'in' then @inPorts else @outPorts
    if portsList[name].isAddressable() and idx
      port = "#{port}[#{idx}]"
    # Ensure we have a bracket context for the current scope
    @bracketContext[type][port] = {} unless @bracketContext[type][port]
    @bracketContext[type][port][scope] = [] unless @bracketContext[type][port][scope]

            ctx.ports.push outport
            @getBracketContext('out', outport, ctx.ip.scope).push ctx
          forwardedOpens.reverse()
          @addToResult result, outport, ip, true for ip in forwardedOpens

    if result.__bracketClosingAfter?.length
      for context in result.__bracketClosingAfter
