Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct copy handling issues #1399

Open
Jooseppi12 opened this issue Mar 28, 2024 · 0 comments
Open

Struct copy handling issues #1399

Jooseppi12 opened this issue Mar 28, 2024 · 0 comments

Comments

@Jooseppi12
Copy link
Member

Given the following F# code:

[<Struct>]
type Position =
    {
        pos_fname: string
        pos_lnum: int
        pos_orig_lnum: int
        pos_bol: int
        pos_cnum: int
    }

    member pos.FileName = pos.pos_fname

    member pos.Line = pos.pos_lnum

    member pos.OriginalLine = pos.pos_orig_lnum

    member pos.Char = pos.pos_cnum

    member pos.AbsoluteOffset = pos.pos_cnum

    member pos.StartOfLine = pos.pos_bol

    member pos.StartOfLineAbsoluteOffset = pos.pos_bol

    member pos.Column = pos.pos_cnum - pos.pos_bol

    member pos.NextLine =
        { pos with
            pos_orig_lnum = pos.OriginalLine + 1
            pos_lnum = pos.Line + 1
            pos_bol = pos.AbsoluteOffset
        }

    member this.EndOfToken(n) =
        let pos = this
        { pos with pos_cnum = pos.pos_cnum + n }

    member pos.AsNewLinePos() = pos.NextLine

    member this.ShiftColumnBy(by) =
        let pos = this
        { pos with
            pos_cnum = pos.pos_cnum + by
        }

    static member Empty =
        {
            pos_fname = ""
            pos_lnum = 0
            pos_orig_lnum = 0
            pos_bol = 0
            pos_cnum = 0
        }

    static member FirstLine(filename) =
        {
            pos_fname = filename
            pos_orig_lnum = 1
            pos_lnum = 1
            pos_bol = 0
            pos_cnum = 0
        }

we end up with code generated with MISSINGVAR like this:

get NextLine(){
    const i={get:() => this, set:(v) => {
      MISSINGVARthis_1=v;
    }};
    const p=this.OriginalLine+1;
    return _c_30.New(i.pos_fname, this.Line+1, p, this.AbsoluteOffset, i.pos_cnum);
  }
Jand42 added a commit that referenced this issue Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant