-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 907: Case expressions #1097
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
treiher
requested changes
Jul 6, 2022
jklmnn
suggested changes
Jul 6, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot assign values to a variable with a case expression, as in this example:
with Universal;
package Test is
type T is range 0 .. 256 with Size => 16;
generic
Channel : Channel with Readable, Writable; -- §S-P-C-RW
session Session with
Initial => Start,
Final => Terminated
is
Message : Universal::Message; -- §S-D-V-T-M, §S-D-V-E-N
Test_Var : T;
begin
state Start is
begin
Channel'Read (Message); -- §S-S-A-RD-V
transition
goto Prepare
if Message'Valid -- §S-S-T-VAT, §S-E-AT-V-V
goto Terminated -- §S-S-T-N
end Start;
state Prepare is
Recv_Type : Universal::Message_Type; -- §S-D-V-T-SC
begin
Recv_Type := Message.Message_Type; -- §S-S-A-A-V
-- §S-S-A-A-MA
Message := Universal::Message'(Message_Type => Universal::MT_Value,
Length => 1,
Value => -- §S-E-CE
(case Recv_Type is
when Universal::MT_Null | Universal::MT_Data => 2,
when Universal::MT_Value => 8,
when Universal::MT_Values => 16,
when Universal::MT_Option_Types => 32,
when Universal::MT_Options => 64,
when Universal::MT_Unconstrained_Data => 128,
when Universal::MT_Unconstrained_Options => 256));
Test_Var := (case Recv_Type is
when Universal::MT_Null | Universal::MT_Data => 2,
when Universal::MT_Value => 8,
when Universal::MT_Values => 16,
when Universal::MT_Option_Types => 32,
when Universal::MT_Options => 64,
when Universal::MT_Unconstrained_Data => 128,
when Universal::MT_Unconstrained_Options => 256);
transition
goto Reply -- §S-S-T-N
exception
goto Terminated -- §S-S-E
end Prepare;
state Reply is
begin
Channel'Write (Message); -- §S-S-A-WR-V
transition
goto Terminated -- §S-S-T-N
end Reply;
state Terminated is null state; -- §S-S-N
end Session;
end Test;
I get the following error:
------------------------------ RecordFlux Bug ------------------------------
RecordFlux 0.6.0-pre
RecordFlux-parser 0.11.0
attrs 21.2.0
icontract 2.6.0
pydantic 1.9.0
pydotplus 2.0.2
ruamel.yaml 0.17.20
z3-solver 4.8.14.0
Optimized: True
Command: /.../rflx generate test.rflx -d out
Traceback (most recent call last):
File "/.../RecordFlux/rflx/cli.py", line 202, in main
args.func(args)
File "/.../RecordFlux/rflx/cli.py", line 260, in generate
Generator(
File "/.../RecordFlux/rflx/generator/generator.py", line 143, in generate
units = self._generate(model, integration)
File "/.../RecordFlux/rflx/generator/generator.py", line 266, in _generate
units.update(self._create_session(s, integration))
File "/.../RecordFlux/rflx/generator/generator.py", line 283, in _create_session
session_generator = SessionGenerator(
File "/.../RecordFlux/rflx/generator/session.py", line 221, in __init__
self._create()
File "/.../RecordFlux/rflx/generator/session.py", line 251, in _create
state_machine = self._create_state_machine()
File "/.../RecordFlux/rflx/generator/session.py", line 370, in _create_state_machine
unit += self._create_states(self._session, composite_globals, is_global)
File "/.../RecordFlux/rflx/generator/session.py", line 861, in _create_states
*[
File "/.../RecordFlux/rflx/generator/session.py", line 864, in <listcomp>
for s in self._state_action(
File "/.../RecordFlux/rflx/generator/session.py", line 1950, in _state_action
result = self._assign(
File "/.../RecordFlux/rflx/generator/session.py", line 2270, in _assign
_unexpected_expression(expression, "in assignment")
File "/.../RecordFlux/rflx/generator/session.py", line 4757, in _unexpected_expression
fatal_fail(
File "/.../RecordFlux/rflx/error.py", line 198, in fatal_fail
_fail(FatalError(), message, subsystem, severity, location)
File "/.../RecordFlux/rflx/error.py", line 209, in _fail
error.propagate()
File "/.../RecordFlux/rflx/error.py", line 162, in propagate
raise self
rflx.error.FatalError: test.rflx:41:22: generator: error: unexpected Case with type universal integer (2 .. 256) in assignment
----------------------------------------------------------------------------
senier
force-pushed
the
issue_907
branch
3 times, most recently
from
July 8, 2022 11:14
4b415d2
to
22ff72d
Compare
jklmnn
previously approved these changes
Jul 8, 2022
treiher
requested changes
Jul 8, 2022
jklmnn
previously approved these changes
Jul 11, 2022
Ref. #907
treiher
approved these changes
Jul 12, 2022
jklmnn
approved these changes
Jul 12, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #907