mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
feat!: Throw errors on missing inputs (#7969)
Previously generators could generate code from inputs that didn't exist and get back the empty string. This silent failure was causing problems for diagnosing issues. This PR changes the behaviour so that an error is thrown. This will break generators which rely on the previous behaviour. Several of our demo blocks needed editing to accomodate this change. Resolves #7665
This commit is contained in:
@@ -38,8 +38,17 @@ export function procedures_defreturn(
|
||||
generator.INDENT,
|
||||
);
|
||||
}
|
||||
const branch = generator.statementToCode(block, 'STACK');
|
||||
let returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
|
||||
let branch = '';
|
||||
if (block.getInput('STACK')) {
|
||||
// The 'procedures_defreturn' block might not have a STACK input.
|
||||
branch = generator.statementToCode(block, 'STACK');
|
||||
}
|
||||
let returnValue = '';
|
||||
if (block.getInput('RETURN')) {
|
||||
// The 'procedures_defnoreturn' block (which shares this code)
|
||||
// does not have a RETURN input.
|
||||
returnValue = generator.valueToCode(block, 'RETURN', Order.NONE) || '';
|
||||
}
|
||||
let xfix2 = '';
|
||||
if (branch && returnValue) {
|
||||
// After executing the function body, revisit this block for the return.
|
||||
|
||||
Reference in New Issue
Block a user