mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Raise error if statement block returns tuple.
This commit is contained in:
@@ -163,6 +163,8 @@ Blockly.Generator.prototype.blockToCode = function(block) {
|
||||
var code = func.call(block, block);
|
||||
if (goog.isArray(code)) {
|
||||
// Value blocks return tuples of code and operator order.
|
||||
goog.asserts.assert(block.outputConnection,
|
||||
'Expecting string from statement block "%s".', block.type);
|
||||
return [this.scrub_(block, code[0]), code[1]];
|
||||
} else if (goog.isString(code)) {
|
||||
if (this.STATEMENT_PREFIX) {
|
||||
|
||||
@@ -737,12 +737,12 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
|
||||
// Options to undo/redo previous action.
|
||||
var undoOption = {};
|
||||
undoOption.text = Blockly.Msg.UNDO;
|
||||
undoOption.enabled = !!this.undoStack_.length > 0;
|
||||
undoOption.enabled = this.undoStack_.length > 0;
|
||||
undoOption.callback = this.undo.bind(this, false);
|
||||
menuOptions.push(undoOption);
|
||||
var redoOption = {};
|
||||
redoOption.text = Blockly.Msg.REDO;
|
||||
redoOption.enabled = !!this.redoStack_.length > 0;
|
||||
redoOption.enabled = this.redoStack_.length > 0;
|
||||
redoOption.callback = this.undo.bind(this, true);
|
||||
menuOptions.push(redoOption);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ Blockly.Lua['lists_indexOf'] = function(block) {
|
||||
var argument1 = Blockly.Lua.valueToCode(block, 'VALUE',
|
||||
Blockly.Lua.ORDER_NONE) || '({})';
|
||||
var functionName;
|
||||
if (block.getTitleValue('END') == 'FIRST') {
|
||||
if (block.getFieldValue('END') == 'FIRST') {
|
||||
functionName = Blockly.Lua.provideFunction_(
|
||||
'first_index',
|
||||
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t, elem)',
|
||||
@@ -155,8 +155,8 @@ Blockly.Lua.lists.gensym_ = function() {
|
||||
Blockly.Lua['lists_getIndex'] = function(block) {
|
||||
// Get element at index.
|
||||
// Note: Until January 2013 this block did not have MODE or WHERE inputs.
|
||||
var mode = block.getTitleValue('MODE') || 'GET';
|
||||
var where = block.getTitleValue('WHERE') || 'FROM_START';
|
||||
var mode = block.getFieldValue('MODE') || 'GET';
|
||||
var where = block.getFieldValue('WHERE') || 'FROM_START';
|
||||
var at = Blockly.Lua.valueToCode(block, 'AT',
|
||||
Blockly.Lua.ORDER_ADDITIVE) || '1';
|
||||
var list = Blockly.Lua.valueToCode(block, 'VALUE',
|
||||
|
||||
@@ -93,7 +93,7 @@ Blockly.Lua['text_indexOf'] = function(block) {
|
||||
Blockly.Lua.ORDER_NONE) || '\'\'';
|
||||
var str = Blockly.Lua.valueToCode(block, 'VALUE',
|
||||
Blockly.Lua.ORDER_NONE) || '\'\'';
|
||||
if (block.getTitleValue('END') == 'FIRST') {
|
||||
if (block.getFieldValue('END') == 'FIRST') {
|
||||
var functionName = Blockly.Lua.provideFunction_(
|
||||
'firstIndexOf',
|
||||
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
|
||||
|
||||
Reference in New Issue
Block a user