pxt icon indicating copy to clipboard operation
pxt copied to clipboard

BUG Converting upvar blocks to JavaScript: TypeError: null is not an object (evaluating 'block.getField('VAR').getText')

Open nodingneu opened this issue 4 years ago • 1 comments

Screenshot 2020-11-06 at 17 33 28

Trying to convert this innocuous, default for each block into JavaScript results in the error

TypeError: null is not an object (evaluating 'block.getField('VAR').getText')

in line 145, loops.js

var variable0 = Blockly.JavaScript.variableDB_.getName(
      block.getField('VAR').getText(), Blockly.Variables.NAME_TYPE);

What's the fix for this?

nodingneu avatar Nov 06 '20 17:11 nodingneu

can be fixed by changing the line to

  var variable0 = Blockly.JavaScript.variableDB_.getName(
      block.getInputTargetBlock('VAR').getField('VAR').getText(), Blockly.Variables.NAME_TYPE);

nodingneu avatar Nov 11 '20 11:11 nodingneu