microsoft / microsoft/pxt

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

Open
#7,597 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
641
Avg merge
12h 4m
Merged PRs (30d)
57

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at generators/javascript/loops.js line 145 and reproduce JavaScript conversion for the default for-each block. Inspect why the block lacks the VAR field before calling getText, then verify the conversion no longer throws and add or update a relevant regression test if one is found nearby.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.