SqlScriptDOM icon indicating copy to clipboard operation
SqlScriptDOM copied to clipboard

EndConversationStatement object has wrong FirstTokenIndex value

Open IVNSTN opened this issue 1 year ago • 2 comments

ScriptDom version: 161.9123 Parser compatibility level: 150

Code example

END CONVERSATION @handle;

Actually, I noticed it on a longer IF-ELSE-END CONVERSATION piece of code, but here is the problem: FirstTokenIndex points not to END keyword but to @handle variable reference which is wrong. On screenshot below FirstTokenIndex should be 178, not 182.

image

LastTokenIndex points here to semicolon position which is correct.

IVNSTN avatar Aug 20 '24 10:08 IVNSTN

I think the issue is that

https://github.com/microsoft/SqlScriptDOM/blob/d84cc30809b29cc5497809c2b0432bf23c412c69/SqlScriptDom/Parser/TSql/TSql90.g#L13602-L13612

is missing a UpdateTokenInfo for End and vResult.

it should be:

endConversationStatement returns [EndConversationStatement vResult = FragmentFactory.CreateFragment<EndConversationStatement>()]
{
    ScalarExpression vConv;
}
    : tEnd:End tConversation:Identifier vConv = expression 
        {
            UpdateTokenInfo(vResult,tEnd);
            Match(tConversation,CodeGenerationSupporter.Conversation);
            vResult.Conversation = vConv;
        }
        endConversationArgumentsOpt[vResult]
    ;

It's a similar issue to #91, and from looking at the grammar files I feel it probably happens in a few other places.

vemoo avatar Aug 27 '24 18:08 vemoo

up

IVNSTN avatar Feb 25 '25 13:02 IVNSTN