Skip to content

Commit 05b803c

Browse files
committed
fix: fix #243 Syntax error if Made block argument name include space
MyBlockのコード <-> Rubyの変換について以下を修正しました。 - 引数にスペースが含まれる場合、コードへの変換に失敗すること - 引数の先頭の文字が大文字である場合、コードへの変換に失敗すること また、argsへの代入を行わなくなったためargsをletではなくconstで宣言します。
1 parent 1c84917 commit 05b803c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib/ruby-generator/procedure.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function (Generator) {
1717
if (methodName.length === 0) {
1818
methodName = 'procedure';
1919
}
20-
let args = [];
20+
const args = [];
2121
const paramNamesIdsAndDefaults =
2222
Generator.currentTarget.blocks.getProcedureParamNamesIdsAndDefaults(block.mutation.proccode);
2323
if (isCall) {
@@ -33,7 +33,12 @@ export default function (Generator) {
3333
args.push(Generator.nosToCode(value));
3434
}
3535
} else {
36-
args = paramNamesIdsAndDefaults[0];
36+
for (let i = 0; i < paramNamesIdsAndDefaults[0].length; i++) {
37+
// Escape identity and Change first letter to lower case.
38+
let paramName = Generator.escapeVariableName(paramNamesIdsAndDefaults[0][i]);
39+
paramName = paramName.replace(/^[A-Z]/, firstLetter => firstLetter.toLowerCase());
40+
args.push(paramName);
41+
}
3742
}
3843
const argsString = args.length > 0 ? `(${args.join(', ')})` : '';
3944
return `${isCall ? '' : 'def self.'}${methodName}${argsString}\n`;

0 commit comments

Comments
 (0)