PLC-lang / PLC-lang/rusty

Structs and Arrays in const-initialization

Open
#288 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

medium-priority
Dominant language
Rust
Stars
362
Forks
75
Avg merge
6d 9h
Merged PRs (30d)
35

Description

PR #279 introduces constant-intialization. Literals or some basic expressions can be evaluated at compile time.

Constant arrays and structs are not properly supported:

VAR_GLOBAL CONSTANT
    x : INT := 3;
    x_arr : ARRAY[0..1] OF INT = [9,8];
    x_strct : MyStruct = (x := 5; y := 7);
END_VAR

VAR_GLOBAL CONSTANT
   a : INT := x; 
   b: INT := x_arr[1];   // does not work
   c: INT := x_strct.y;   // does not work
END_VAR

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing PR #279, which introduced constant initialization, then reproduce the array and struct examples in this issue. Trace how constant arrays and structs are evaluated and accessed; done means the indexed array value and struct field value initialize correctly at compile time.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.