Recent

Author Topic: “case (a,b) of...” doesn’t compile  (Read 1627 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5277
  • Compiler Developer
Re: “case (a,b) of...” doesn’t compile
« Reply #15 on: September 28, 2023, 10:01:41 pm »
The solution should be quite simple:
Code: Pascal  [Select][+][-]
  1.               fieldvs:=nil;
  2.               if token=_ID then
  3.                 begin
  4.                   sorg:=orgpattern;
  5.                   hs:=pattern;
  6.                   searchsym(hs,srsym,srsymtable);
  7.                   if not(assigned(srsym) and (srsym.typ in [typesym,unitsym])) then
  8.                     begin
  9.                       consume(_ID);
  10.                       consume(_COLON);
  11.                       fieldvs:=cfieldvarsym.create(sorg,vs_value,generrordef,[]);
  12.                       variantdesc^^.variantselector:=fieldvs;
  13.                       symtablestack.top.insertsym(fieldvs);
  14.                     end;
  15.                 end;
  16.               read_anon_type(casetype,true);

Would you please file a bug report with your fix or a merge request? (Best with a test case)

In addition to that, the anonymous enumeration cannot be used without an identifier which, if it is allowed, should also be allowed without the identifier but, if allowed, would leave no way to reference the enumeration constants outside the record's definition.

If there is no selector field then you don't access these values anyway. Only if there is a field you'd have a need to use them.

Warfley

  • Hero Member
  • *****
  • Posts: 1468
Re: “case (a,b) of...” doesn’t compile
« Reply #16 on: September 29, 2023, 12:42:19 am »
Would you please file a bug report with your fix or a merge request? (Best with a test case)
https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/500

440bx

  • Hero Member
  • *****
  • Posts: 3620
Re: “case (a,b) of...” doesn’t compile
« Reply #17 on: September 29, 2023, 08:02:32 am »
In addition to that, the anonymous enumeration cannot be used without an identifier which, if it is allowed, should also be allowed without the identifier but, if allowed, would leave no way to reference the enumeration constants outside the record's definition.

If there is no selector field then you don't access these values anyway. Only if there is a field you'd have a need to use them.
Yes, you're right.  Thank you for correcting that.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018