Skip to content

Front end: := on a UDT field in a single-line function body, and CRLF line endings #230

Closed

Description

@letiep97

Summary

Two small front-end gaps that stop otherwise valid scripts before analysis.

Versions

pineforge-codegen 1.6.1

1. Field reassignment in a single-line function body

//@version=6
strategy('Field assignment')
type State
    int value = 0
set(State s) => s.value := 1
var State s = State.new()
set(s)
plot(s.value)

PARSER 5:25 Unexpected token COLON_EQUALS(':=') after statement; expected a line break or comma

The same body written on its own indented line translates.

2. CRLF line endings

The three-line script //@version=6, strategy('Newlines'), plot(close) translates with LF endings and fails with CRLF:

LEXER 2:21 Unexpected character: '\r' (and on every following line)

Scripts saved by Windows editors arrive with CRLF. Accepting \r\n (and a lone \r) as a line break would avoid every host having to normalise.

Activity

  1. letiep97 commented on Oct 20, 2026

    @letiep97
    Author

    Both still reproduce on main (aebad8c). Pointers in case they help:

    • One-line body. _parse_func_def and _parse_method_def read a single expression after => (parser.py#L921-L932, #L1050-L1061). _parse_arm_line (parser.py#L1204) already parses a one-line block, including a field target such as o.f := v, for switch arms. Using it for one-line function and method bodies should cover this; whatever reads is_single_expr may need a look.
    • CRLF. Only library sources are normalized (normalize_library_text, library_modules.py#L61-L67). Applying the same normalization to the main source at the top of _parse_bounded (init.py#L25-L33), before the pragma scan and the lexer, would cover it. Diagnostic line numbers don't change for \r\n.
  2. luisleo526 commented on Oct 25, 2026

    @luisleo526
    Contributor

    Thank you for the report. Part 2 (CRLF): confirmed in the v1.7.0 source, \r is rejected by the lexer. This is not fixed in v1.7.0. A fix is being written: \r\n and a lone \r will be treated as a line break, with the same output and the same line numbers as the LF form. We expect to open the pull request on 2026-10-26. Part 1 (:= on a UDT field in a single-line function body): confirmed in the v1.7.0 source and not fixed in v1.7.0; we plan to open a pull request for it on 2026-10-30.

  3. luisleo526 commented on Oct 25, 2026

    @luisleo526
    Contributor

    Update on part 2 (CRLF): the fix is up for review in #252. One precision to my earlier note: \r\n is folded to \n everywhere, including inside strings, and a lone \r ends a line in code and comments; a lone \r inside a string literal is kept as part of the string. Part 1 (:= on a UDT field in a single-line function body) is still planned for a pull request on 2026-10-30.

  4. luisleo526 commented on Oct 25, 2026

    @luisleo526
    Contributor

    Part 2 (CRLF / lone CR line endings) is fixed by #252, merged to main; it ships in the next codegen release, 1.8.0 (I will confirm here when it is published).

    Reopening, because part 1 (:= on a UDT field in a single-line function body) is not fixed yet: the merge closed this issue automatically. Part 1 is still planned for a pull request on 2026-10-30.

  5. luisleo526 commented on Oct 26, 2026

    @luisleo526
    Contributor

    Both parts of this issue are fixed on main:

    Both ship in codegen 1.8.0. Closing this issue as fixed on main; I will confirm here when 1.8.0 is published.

  6. luisleo526 commented on Oct 26, 2026

    @luisleo526
    Contributor

    Both parts of this issue are fixed on main:

    Both ship in codegen 1.8.0. Closing this issue as fixed on main; I will confirm here when 1.8.0 is published.

  7. letiep97 commented on Oct 28, 2026

    @letiep97
    Author

    Verified both parts on main (11b5ca5, with engine 1.6.1): the := on a UDT field in a one-line function body now translates and runs, and the CRLF file from this issue now translates. Thank you for the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions