I just found this very odd bug. Here is how to reproduce it.
Create a new block named "constructor" (case sensitive) in any category. It can be a command, reporter, or predicate.
The make a block window will not close when you press OK, and the block will not show up on the left.
Press cancel on the make a block window
Click to another category.
Click back to the category the "constructor" was created in. The pallet will be blacked out, and blocks cannot be taken out of it.
This problem is persistent. Saving and loading the project will not fix it. I am currently using 10.0.13 on this website. Is the something known about? Are there any other words to avoid? Thanks!
Yeah, that's extremely odd. Aside from the lack of blocks in the constructor and control category, some other weird stuff seems to happen as a result. You can't seem to make custom blocks, importing libraries makes it freak out, and when I import a library that adds a category, it completely covers the icons in the top left corner, rendering them unusable, and impossible to interact with. I'm not sure why this is, but it's certainly an interesting bug.
I checked the console while creating a "constructor" block, and followed an error to this.
// look up the spec
info = this.labelParts[spec];
if (!info) {
throw new Error('label part spec not found: "' + spec + '"');
}
// create the morph
switch (info.type) {
case 'input':
part = new InputSlotMorph(null, null, info.menu);
part.onSetContents = info.react || null;
break;
case 'text entry':
part = new TextSlotMorph();
break;
case 'slot':
part = new ArgMorph(info.kind);
break;
case 'boolean':
part = new BooleanSlotMorph();
break;
case 'symbol':
part = new BlockSymbolMorph(info.name);
part.size = this.fontSize * (info.scale || 1);
part.color = info.color || WHITE;
part.shadowColor = this.color.darker(this.labelContrast);
part.shadowOffset = MorphicPreferences.isFlat ?
ZERO : this.embossing;
part.fixLayout();
break;
case 'c':
part = new CSlotMorph();
break;
case 'command slot':
part = new CommandSlotMorph();
break;
case 'ring':
part = new RingMorph();
part.color = SpriteMorph.prototype.blockColor.other;
part.selector = info.selector;
part.setSpec(info.spec);
part.isDraggable = true;
break;
case 'ring slot':
switch (info.kind) {
case 'command':
part = new RingCommandSlotMorph();
break;
case 'reporter':
part = new RingReporterSlotMorph();
break;
case 'predicate':
part = new RingReporterSlotMorph(true);
break;
default:
throw new Error('unknown ring kind: "' + info.kind + '"');
}
break;
case 'template':
part = new TemplateSlotMorph(info.label);
break;
case 'color':
part = new ColorSlotMorph();
break;
case 'break':
part = new Morph();
part.setExtent(ZERO);
part.isBlockLabelBreak = true;
part.getSpec = () => '%br';
break;
case 'variable':
part = new TemplateSlotMorph(info.label);
part = new ReporterBlockMorph();
part.category = 'variables';
part.color = SpriteMorph.prototype.blockColor.variables;
part.setSpec(localize('Input name'));
break;
case 'multi':
part = new MultiArgMorph(
info.slots,
info.label,
info.min || 0,
spec,
null, null, null, null, null,
info.infix,
info.collapse,
info.dflt,
info.group
);
part.maxInputs = info.max;
part.initialSlots = Math.max( // this needs some fixing
part.initialSlots,
isNil(info.min) ? 0 : +info.min,
isNil(info.defaults) ? 0 : +info.defaults
);
for (i = 0; i < info.defaults || 0; i += 1) {
part.addInput();
}
break;
default:
//error is thrown here
throw new Error('unknown label part type: "' + info.type + '"');
}
This seems to suggest the the constructor block is empty, and has no lables or inputs. I downloaded the project's XML and took a look at it.
Very odd. This looks basically the same.
My best theory so far is that the name "constructor" somehow creates a block that has no labels or inputs, that isn't render-able.
I think you're seeing two separate problems. The one about what's in the project's XML is the result of the make-a-block dialog failing, leaving an empty procedure in its own category. What's more interesting, I think, is what makes the dialog fail, and by the time you have an XML to look at it's too late to explore that part.
The s attribute is the block spec, basically just a string representation of the block name, and where all it's inputs go.
<header> and <code> are used for codification, <translations> is used for language translations that you can put in blocks, and <inputs> defines all the inputs' info, such as type, default value, menu, etc.
Basically, that xml is 100% correct and not broken at all, the only thing that is broken, is snap somehow doing something with the constructor name (I know it's the object initialization method name in javascript, so that might be part of why it's breaking, though I don't know why it's doing this).
I think you are correct. I edited the XML of a broken project and changed the name of the block to something other than constructor, and my project was fixed and worked normally.