Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Support set types #2024

@rebcabin

Description

@rebcabin

The following generates a good error message, but the lack of set types is a severe limiitation.

INTEGER_KINDS   : set[i32] = {1, 2, 4, 8}
LOGICAL_KINDS   : set[i32] = {1, 2, 4}
REAL_KINDS      : set[i32] = {4, 8}
COMPLEX_KINDS   : set[i32] = {4, 8}
CHARACTER_KINDS : set[i32] = {1}
/Users/brian/CLionProjects/lpython/src/bin/python /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/lasr_parser.py 
code generation error: Variable type not supported 6
  --> /Users/brian/CLionProjects/lpython/lasr/LP-pycharm/lasr_parser.py:58:1
   |
58 | CHARACTER_KINDS : set[i32] = {1}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

The workaround is undesirable (that's what "severe" means):

INTEGER_KINDS   : dict[i32, i32] = {1: 1, 2: 2, 4: 4, 8: 8}
LOGICAL_KINDS   : dict[i32, i32] = {1: 1, 2: 2, 4: 4}
REAL_KINDS      : dict[i32, i32] = {4: 4, 8: 8}
COMPLEX_KINDS   : dict[i32, i32] = {4: 4, 8: 8}
CHARACTER_KINDS : dict[i32, i32] = {1: 1}

The workaround hints at a possible easy fix.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestseverenot blocker, but causes undesirable workarounds

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions