diff --git a/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts b/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts index 0bd5ab102..504750b46 100644 --- a/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts +++ b/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts @@ -1708,7 +1708,7 @@ export class AlphaTex1LanguageHandler implements IAlphaTexLanguageImportHandler let tbi = 0; let typeAndStyle = true; let typeSet = false; - while (typeAndStyle) { + while (typeAndStyle && tbi < (p.arguments?.arguments.length ?? 0)) { switch (p.arguments!.arguments[tbi].nodeType) { case AlphaTexNodeType.Ident: case AlphaTexNodeType.String: @@ -2141,7 +2141,7 @@ export class AlphaTex1LanguageHandler implements IAlphaTexLanguageImportHandler let typeAndStyle = true; let typeSet = false; - while (typeAndStyle) { + while (typeAndStyle && tbi < (p.arguments?.arguments.length ?? 0)) { switch (p.arguments!.arguments[tbi].nodeType) { case AlphaTexNodeType.Ident: case AlphaTexNodeType.String: @@ -2411,9 +2411,13 @@ export class AlphaTex1LanguageHandler implements IAlphaTexLanguageImportHandler argStartIndex: number, exact: boolean ): BendPoint[] | undefined { - let args = p.arguments!.arguments; + if (!p.arguments) { + return undefined; + } + + let args = p.arguments.arguments; let remainingArgs = args.length - argStartIndex; - let errorNode: AlphaTexAstNode = p.arguments!; + let errorNode: AlphaTexAstNode = p.arguments; // unwrap value list if (remainingArgs > 0 && args[argStartIndex].nodeType === AlphaTexNodeType.Arguments) { diff --git a/packages/alphatab/test/importer/__snapshots__/AlphaTexImporter.test.ts.snap b/packages/alphatab/test/importer/__snapshots__/AlphaTexImporter.test.ts.snap index 26a102a43..806c9aaf2 100644 --- a/packages/alphatab/test/importer/__snapshots__/AlphaTexImporter.test.ts.snap +++ b/packages/alphatab/test/importer/__snapshots__/AlphaTexImporter.test.ts.snap @@ -6033,13 +6033,39 @@ exports[`AlphaTexImporterTest > errors > at219 > bendstyle > lexer-diagnostics 1 exports[`AlphaTexImporterTest > errors > at219 > bendstyle > parser-diagnostics 1`] = `[]`; -exports[`AlphaTexImporterTest > errors > at219 > bendstyle > semantic-diagnostics 1`] = `[]`; +exports[`AlphaTexImporterTest > errors > at219 > bendstyle > semantic-diagnostics 1`] = ` +[ + Map { + "code" => 212, + "severity" => 2, + "message" => "Unrecogized property 'invalid', expected one of nh,ah,th,ph,sh,fh,v,vw,sl,ss,sib,sia,sou,sod,psu,psd,h,lht,g,ac,hac,ten,tr,pm,st,lr,x,t,turn,iturn,umordent,lmordent,string,hide,b,be,lf,rf,acc,slur,-,f,fo,vs,v,vw,s,p,tt,d,dd,su,sd,cre,dec,spd,sph,spu,spe,slashed,ds,glpf,glpt,waho,wahc,legatoorigin,timer,tu,txt,lyrics,tb,tbe,bu,bd,au,ad,ch,gr,dy,tempo,volume,balance,tp,barre,rasg,ot,instrument,bank,fermata,beam,restdisplaypitch", + "start" => Map { + "col" => 25, + "line" => 1, + "offset" => 24, + }, + }, +] +`; exports[`AlphaTexImporterTest > errors > at219 > bendtype > lexer-diagnostics 1`] = `[]`; exports[`AlphaTexImporterTest > errors > at219 > bendtype > parser-diagnostics 1`] = `[]`; -exports[`AlphaTexImporterTest > errors > at219 > bendtype > semantic-diagnostics 1`] = `[]`; +exports[`AlphaTexImporterTest > errors > at219 > bendtype > semantic-diagnostics 1`] = ` +[ + Map { + "code" => 212, + "severity" => 2, + "message" => "Unrecogized property 'invalid', expected one of nh,ah,th,ph,sh,fh,v,vw,sl,ss,sib,sia,sou,sod,psu,psd,h,lht,g,ac,hac,ten,tr,pm,st,lr,x,t,turn,iturn,umordent,lmordent,string,hide,b,be,lf,rf,acc,slur,-,f,fo,vs,v,vw,s,p,tt,d,dd,su,sd,cre,dec,spd,sph,spu,spe,slashed,ds,glpf,glpt,waho,wahc,legatoorigin,timer,tu,txt,lyrics,tb,tbe,bu,bd,au,ad,ch,gr,dy,tempo,volume,balance,tp,barre,rasg,ot,instrument,bank,fermata,beam,restdisplaypitch", + "start" => Map { + "col" => 20, + "line" => 1, + "offset" => 19, + }, + }, +] +`; exports[`AlphaTexImporterTest > errors > at219 > bracketextendmode > lexer-diagnostics 1`] = `[]`; @@ -6379,7 +6405,20 @@ exports[`AlphaTexImporterTest > errors > at219 > whammybartype > lexer-diagnosti exports[`AlphaTexImporterTest > errors > at219 > whammybartype > parser-diagnostics 1`] = `[]`; -exports[`AlphaTexImporterTest > errors > at219 > whammybartype > semantic-diagnostics 1`] = `[]`; +exports[`AlphaTexImporterTest > errors > at219 > whammybartype > semantic-diagnostics 1`] = ` +[ + Map { + "code" => 212, + "severity" => 2, + "message" => "Unrecogized property 'invalid', expected one of nh,ah,th,ph,sh,fh,v,vw,sl,ss,sib,sia,sou,sod,psu,psd,h,lht,g,ac,hac,ten,tr,pm,st,lr,x,t,turn,iturn,umordent,lmordent,string,hide,b,be,lf,rf,acc,slur,-,f,fo,vs,v,vw,s,p,tt,d,dd,su,sd,cre,dec,spd,sph,spu,spe,slashed,ds,glpf,glpt,waho,wahc,legatoorigin,timer,tu,txt,lyrics,tb,tbe,bu,bd,au,ad,ch,gr,dy,tempo,volume,balance,tp,barre,rasg,ot,instrument,bank,fermata,beam,restdisplaypitch", + "start" => Map { + "col" => 21, + "line" => 1, + "offset" => 20, + }, + }, +] +`; exports[`AlphaTexImporterTest > sync 1`] = ` Map {