mermaid
mermaid copied to clipboard
Deactivating participants starting with "x" causes syntax error in sequence diagram
Describe the bug In sequence diagrams: When deactivating participants starting with "x" using the shortcut version with a message a syntax error is caused.
To Reproduce In live editor
sequenceDiagram
xAlice->>+John: John, can you hear me?
John-->>-xAlice: Hi Alice, I can hear you!
creates a "Syntax Error".
The following workaround (without the shortcut) is possible:
sequenceDiagram
xAlice->>+John: John, can you hear me?
John-->>xAlice: Hi Alice, I can hear you!
deactivate John
Also letting "xAlice" not start with "x" works or adding a space before the "x".
Expected behavior graph is drawn
Desktop (please complete the following information):
- OS: Debian stretch
- Browser Firefox
- Version 73.0.1
Additional context I assume the parser mixes this with the "-x" symbol.
I'm not sure if this is a workaround or the solution: simply use spaces to disambiguate. The following renders fine:
sequenceDiagram
xAlice ->>+ John: John, can you hear me?
John -->>- xAlice: Hi Alice, I can hear you!
@antonhattendorf Can you try @vassudanagunta suggestion and see if that works for you? If so, I am thinking that we would close this as Wont Fix
I consider this is a parsing error that could be fixed. But probably this is not what we really need
Firstly, you get pretty descriptive parsing error
Expecting '+', '-', 'ACTOR', got 'SOLID_CROSS'
In programming languages variables cannot be named after reserved words or operators. -x
as a special operator. Think about actor as about variable.
To avoid this and use keywords inside actors there is a special syntax:
sequenceDiagram
participant Alice as Alice whatever you want including arrows -- >, crosses -x etc
Alice ->>+ John: John, can you hear me?
John -->>- Alice: Hi Alice, I can hear you!
sequenceDiagram
participant Alice as Alice whatever you want including arrows -- >, crosses -x etc
Alice ->>+ John: John, can you hear me?
John -->>- Alice: Hi Alice, I can hear you!