Language: accept well-defined programs with parameters in constants, typed/bounded parameters, loop(n) and block-local declarations

Open
#529 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
compilers, testing

Research direction

Start with the parser, scope lowering, type checker, and analysis paths named in the issue, then read docs/source/language-design.md and locate language.md. Add coverage for each listed program on both engines, plus a fuzzer or checker test. Done means all cases parse and type-check, analysis either computes a sound result or reports "not implemented" with the construct named, and both language documents describe the accepted forms.

Written by the indexing model from the issue text.

Description

area: language enhancement priority: medium

Found while writing the P6 design note (#513). Programs with a well-defined semantics that the parser, the scope lowering or the type checker reject today (all on main). Per the language principle (docs/source/language-design.md), they must be accepted; what the analysis cannot compute ends with "not implemented" naming the construct.

Cases

  1. A constant defined from a parameter: param p: real; const q = 1 - p; → "Variable used in constant definition is not a constant".
  2. Parameters of other types or with bounds: param b: bool;, param n: nat[0, 5]; → parser error. (A result in n holds for all natural n, so ignoring the bound in the analysis is sound; the bound may still be checked where values are known.)
  3. loop(n) with param n: nat → parser error; it should parse and end in "not implemented" (or be unrolled symbolically, if a rule covers it).
  4. Scope lowering: the same name declared in two blocks with different types, and local real/dist declarations, are rejected at parse time.

Not in scope: param x: dist (an unknown distribution has no simple PGF semantics).

Decided on #513: the keyword param stays (no rename to const).

Done when

  • Each case parses and type-checks; the analysis computes it or ends with "not implemented" naming the construct — never a wrong or approximate result.
  • Tests per case on both engines, and a fuzzer or checker test that generates such programs.
  • language.md and language-design.md describe the accepted forms.
Dominant language
Python
Stars
6
Forks
2
Avg merge
1h 52m
Merged PRs (30d)
187

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

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.

More from LKlinke/Prodigy

All issues in LKlinke/Prodigy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.