peter-rl / suschlik.de wrote:
> I don't have a strong opinion whether defining a writer member should
> be possible or not.

I suggest banning it (barely-tested patch):

--- a/struct.c
+++ b/struct.c
@@ -12,6 +12,7 @@
 #include "internal.h"
 #include "vm_core.h"
 #include "id.h"
+#include "symbol.h"
 
 /* only for struct[:field] access */
 #define AREF_HASH_THRESHOLD (10)
@@ -510,6 +511,10 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
     rest = rb_ary_tmp_new(argc);
     for (i=0; i<argc; i++) {
 	id = rb_to_id(argv[i]);
+	if (is_attrset_id(id)) {
+	    rb_raise(rb_eArgError, "invalid struct member: %+"PRIsVALUE,
+		     argv[i]);
+	}
 	RARRAY_ASET(rest, i, ID2SYM(id));
 	rb_ary_set_len(rest, i+1);
     }
~~~

$ ./ruby -e 'Struct.new(:foo=)'
-e:1:in `new': invalid struct member: :foo= (ArgumentError)
        from -e:1:in `<main>'