Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 53efd62

Browse files
vishwacsenaVishwac Sena Kannan
andauthored
fix #696 (#707)
Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent e3e08c7 commit 53efd62

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

packages/lu/src/parser/lufile/parseFileContents.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,17 @@ const parseFeatureSections = function(parsedContent, featuresToProcess) {
437437
// We are only interested in extracting features and setting things up here.
438438
(featuresToProcess || []).forEach(section => {
439439
if (section.Type === INTENTTYPE) {
440-
// verify intent exists
441-
if (!section.Features || section.Roles) {
442-
// Intents can only have features and nothing else.
440+
// Intents can only have features and nothing else.
441+
if (section.Roles) {
443442
let errorMsg = `Intents can only have usesFeature and nothing else. Invalid definition for "${section.Name}".`;
444443
let error = BuildDiagnostic({
445444
message: errorMsg,
446445
context: section.ParseTree.newEntityDefinition().newEntityLine()
447446
})
448447
throw (new exception(retCode.errorCode.INVALID_INPUT, error.toString(), [error]));
449448
}
449+
if (!section.Features) return;
450+
// verify intent exists
450451
section.Name = section.Name.replace(/[\'\"]/g, "");
451452
let intentExists = parsedContent.LUISJsonStructure.intents.find(item => item.name === section.Name);
452453
if (intentExists !== undefined) {

packages/lu/test/parser/lufile/parseFileContents.modelAsFeature.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ describe('Model as feature definitions', function () {
1919
.catch(err => done())
2020
});
2121

22-
it('Intent can only have features and nothing else empty throws', function (done) {
22+
it('Intent can have empty uses feature assignment line', function (done) {
2323
let luFile = `
24-
@ intent xyz
24+
## None
25+
- all of them
26+
- i want them all
27+
- i want to all of them
28+
29+
@ intent None
2530
`;
2631

2732
parseFile.parseFile(luFile)
28-
.then(res => done(res))
29-
.catch(err => done())
33+
.then(res => done())
34+
.catch(err => done(err))
3035
});
3136

3237
it('Intent must be defined before a feature can be added to it.', function(done) {
@@ -849,4 +854,4 @@ describe('Model as feature definitions', function () {
849854
})
850855

851856
})
852-
});
857+
});

0 commit comments

Comments
 (0)