nadesiko3 3.3.6 → 3.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1028,7 +1028,7 @@ export class NakoParser extends NakoParserBase {
1028
1028
  }
1029
1029
  }
1030
1030
 
1031
- /** @returns {import('./nako3').Ast | null | undefined} */
1031
+ /** @returns {import('./nako3.mjs').Ast | null | undefined} */
1032
1032
  yDainyu () {
1033
1033
  const map = this.peekSourceMap()
1034
1034
  const dainyu = this.get() // 代入
@@ -1051,14 +1051,15 @@ export class NakoParser extends NakoParserBase {
1051
1051
  };
1052
1052
  }
1053
1053
  // 一般的な変数への代入
1054
+ const word2 = this.getVarName(word)
1054
1055
  return {
1055
- type: 'let', name: word,
1056
+ type: 'let', name: word2,
1056
1057
  value: value, josi: '',
1057
1058
  ...map, end: this.peekSourceMap()
1058
1059
  }
1059
1060
  }
1060
1061
 
1061
- /** @returns {import('./nako3').Ast | null | undefined} */
1062
+ /** @returns {import('./nako3.mjs').Ast | null | undefined} */
1062
1063
  ySadameru () {
1063
1064
  const map = this.peekSourceMap()
1064
1065
  const sadameru = this.get() // 定める
@@ -1075,7 +1076,7 @@ export class NakoParser extends NakoParserBase {
1075
1076
  };
1076
1077
  }
1077
1078
 
1078
- /** @returns {import('./nako3').Ast | null | undefined} */
1079
+ /** @returns {import('./nako3.mjs').Ast | null | undefined} */
1079
1080
  yIncDec () {
1080
1081
  const map = this.peekSourceMap()
1081
1082
  const action = this.get() // (増やす|減らす)
@@ -1110,7 +1111,7 @@ export class NakoParser extends NakoParserBase {
1110
1111
  };
1111
1112
  }
1112
1113
 
1113
- /** @returns {import('./nako3').Ast | null | undefined} */
1114
+ /** @returns {import('./nako3.mjs').Ast | null | undefined} */
1114
1115
  yCall () {
1115
1116
  if (this.isEOF()) { return null }
1116
1117
 
@@ -1933,15 +1934,16 @@ export class NakoParser extends NakoParserBase {
1933
1934
  // check word name
1934
1935
  const f = this.findVar(word.value)
1935
1936
  if (!f) { // 変数が見つからない
1936
- if (this.funcLevel === 0 && word.value.indexOf('__') < 0) {
1937
- const gname = this.modName + '__' + word.value
1938
- word.value = gname
1937
+ if (this.funcLevel === 0) { // global
1938
+ let gname = word.value
1939
+ if (gname.indexOf('__') < 0) { gname = this.modName + '__' + word.value }
1939
1940
  this.funclist[gname] = {type: 'var', value: ''}
1940
- } else {
1941
+ word.value = gname
1942
+ } else { // local
1941
1943
  this.localvars[word.value] = {type: 'var', value: ''}
1942
1944
  }
1943
1945
  }
1944
- if (f && f.scope === 'global') {
1946
+ else if (f && f.scope === 'global') {
1945
1947
  word.value = f.name
1946
1948
  }
1947
1949
  return word
@@ -1,7 +1,7 @@
1
1
  // なでしこバージョン
2
2
  export default {
3
- version: '3.3.6',
3
+ version: '3.3.7',
4
4
  major: 3,
5
5
  minor: 3,
6
- patch: 6
6
+ patch: 7
7
7
  }
@@ -105,4 +105,17 @@ F
105
105
  `, '3\n4')
106
106
  })
107
107
  */
108
+ it('「代入」文が正しく動作しない #1208', () => {
109
+ cmp(`
110
+ A=10
111
+ 20をBに代入。
112
+ Aを表示。
113
+ Bを表示。
114
+ テスト。
115
+ ●テストとは
116
+ Aを表示。
117
+ Bを表示。
118
+ ここまで。
119
+ `, '10\n20\n10\n20')
120
+ })
108
121
  })