diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
index 2e62c598439aff226173011b18a7b369238d13be..1747d541bbb7138a3faf7db82e4015d2f06ddfa5 100644
--- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
@@ -741,5 +741,10 @@ describe('mp:compiler-extra', () => {
'{{item.m2}}',
'with(this){var l0=__map(list,function(item,index){var $orig=__get_orig(item);var m0=test(item.id);var m1=m0?test(item.type):null;var m2=m0&&m1?test("item"):null;return{$orig:$orig,m0:m0,m1:m1,m2:m2}});$mp.data=Object.assign({},{$root:{l0:l0}})}'
)
+ assertCodegen(
+ '{{test(item.list)}}',
+ '{{item.m0}}',
+ 'with(this){var l0=__map(list,function(item,index){var $orig=__get_orig(item);var g0=Object.values(item.list);var m0=g0.length?test(item.list):null;return{$orig:$orig,g0:g0,m0:m0}});$mp.data=Object.assign({},{$root:{l0:l0}})}'
+ )
})
})
diff --git a/packages/uni-template-compiler/lib/script/traverse/member-expr.js b/packages/uni-template-compiler/lib/script/traverse/member-expr.js
index 3a59a6d84b9c3782fd37b67e0fa18b6bf4ff1bb3..70aba6c2346f0a479ece2f21105d2a44190c4e7d 100644
--- a/packages/uni-template-compiler/lib/script/traverse/member-expr.js
+++ b/packages/uni-template-compiler/lib/script/traverse/member-expr.js
@@ -4,7 +4,8 @@ const traverse = require('@babel/traverse').default
const {
VAR_ROOT,
IDENTIFIER_METHOD,
- IDENTIFIER_FILTER
+ IDENTIFIER_FILTER,
+ IDENTIFIER_GLOBAL
} = require('../../constants')
function isMatch (name, forItem, forIndex) {
@@ -69,7 +70,7 @@ function findTest (path, state) {
const objectName = node.object.name
const property = node.property
const propertyName = property.name
- if (objectName === VAR_ROOT || (names.includes(objectName) && (propertyName === IDENTIFIER_METHOD || propertyName === IDENTIFIER_FILTER))) {
+ if (objectName === VAR_ROOT || (names.includes(objectName) && (propertyName === IDENTIFIER_METHOD || propertyName === IDENTIFIER_FILTER || propertyName === IDENTIFIER_GLOBAL))) {
let property
traverse(testOrig, {
noScope: true,