From 686d680ea3e295c584def7e7b98e5d263873f2d2 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 22 Jan 2021 16:38:25 +0100 Subject: [PATCH] io/key,io/pointer: forbid nil tags for InputOps Forcing a non-nil tag ensures that all handler tags are either unique, or intentionally equal. Additionally, a nil tag has special meaning in FocusOps. Signed-off-by: Elias Naur --- io/key/key.go | 3 +++ io/pointer/pointer.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/io/key/key.go b/io/key/key.go index 8b11caf7..8d951d9f 100644 --- a/io/key/key.go +++ b/io/key/key.go @@ -121,6 +121,9 @@ func (m Modifiers) Contain(m2 Modifiers) bool { } func (h InputOp) Add(o *op.Ops) { + if h.Tag == nil { + panic("Tag must be non-nil") + } data := o.Write1(opconst.TypeKeyInputLen, h.Tag) data[0] = byte(opconst.TypeKeyInput) } diff --git a/io/pointer/pointer.go b/io/pointer/pointer.go index 9e054fbc..b112bfde 100644 --- a/io/pointer/pointer.go +++ b/io/pointer/pointer.go @@ -189,6 +189,9 @@ func (op CursorNameOp) Add(o *op.Ops) { } func (h InputOp) Add(o *op.Ops) { + if h.Tag == nil { + panic("Tag must be non-nil") + } data := o.Write1(opconst.TypePointerInputLen, h.Tag) data[0] = byte(opconst.TypePointerInput) if h.Grab {