reject_plus_text.mx raw

   1  // expected: '+' is not allowed for text concatenation
   2  //
   3  // '+' on text was accepted by stage4 and rejected by legacy, in every spelling
   4  // where BOTH operands were []byte (W29). Legacy's rule is loader's
   5  // CheckPlusOnText, which tests either operand for text; the stage4 check tested
   6  // only the LEFT operand and only for the string Basic, so `a + b` on two
   7  // []byte values compiled here and produced a concatenation, while
   8  // `"a" + "b"` was already refused. Two compilers disagreeing about which
   9  // programs exist is the one thing wood law does not allow.
  10  //
  11  // The rule is a main-module rule: a dependency package and the toolchain keep
  12  // '+' (legacy gates on Module.Main), which is why the same check is not applied
  13  // to imports.
  14  package main
  15  
  16  func main() {
  17  	// Termination first: a batch program must still be stoppable, and the entry
  18  	// rule fires before the restriction under test, so without this the fixture
  19  	// reports the missing shutdown arm instead of the '+' it exists to reject.
  20  	select {
  21  	case <-shutdown:
  22  		return
  23  	default:
  24  	}
  25  	a := []byte("x")
  26  	b := []byte("y")
  27  	s := a + b
  28  	println(s)
  29  }
  30