blockpy-edu / blockpy

Blockly that's more Python than JavaScript, powered with Skulpt
Apache License 2.0
401 stars 133 forks source link

Can't translate block to text when using CORGIS w/ a variable argument #116

Open thomaswp opened 1 year ago

thomaswp commented 1 year ago

The blocks-to-text translations stops working if I use a CORGIS get function with a variable as the argument.

For example, this code works fine...

import airlines

print(airlines.get('Airport.Name','Airport.Code','ATL'))

However, if I use a variable in the airlines.get call, the code can't be translated back to python anymore.

import airlines

code = 'ATL'
print(airlines.get('Airport.Name','Airport.Code',code))

It still run in python, and editing the python updates the blocks, but not vice-versa. The line does turn blue (instead of the brown of a dataset, or of uncompilable code)

image

Stack trace:

Uncaught TypeError: Cannot read properties of undefined (reading 'match')
    at Blockly.Python.finish (bootstrap:52:1)
    at Blockly.Generator.workspaceToCode (blockly.js?4826734f:862:39)
    at BlockMirrorBlockEditor.getCode (blockpy.js:862:21)
    at BlockMirrorBlockEditor.changed (blockpy.js:916:5)
    at Blockly.Workspace.fireChangeListener (blockly.js?4826734f:339:447)
    at Blockly.Events.fireNow_ (blockly.js?4826734f:40:391)
Blockly.Python.finish @ bootstrap:52
Blockly.Generator.workspaceToCode @ blockly.js?4826734f:862
BlockMirrorBlockEditor.getCode @ blockpy.js:862
BlockMirrorBlockEditor.changed @ blockpy.js:916
Blockly.Workspace.fireChangeListener @ blockly.js?4826734f:339
Blockly.Events.fireNow_ @ blockly.js?4826734f:40
setTimeout (async)
Blockly.Events.fire @ blockly.js?4826734f:40
Blockly.BlockDragger.fireDragEndEvent_ @ blockly.js?4826734f:310
Blockly.BlockDragger.endBlockDrag @ blockly.js?4826734f:309
Blockly.Gesture.handleUp @ blockly.js?4826734f:434
Blockly.TouchGesture.handleUp @ blockly.js?4826734f:645
h @ blockly.js?4826734f:780

Since using user input with data is a core learning objective, I often encourage my students to do this, and I don't recall it breaking before, so perhaps this is a new issue?

thomaswp commented 1 year ago

Confirmed this is still an issue on the UDel instance.