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

Renaming type alias misses alias-as-constructor #972

Closed
adamdicarlo0 opened this issue May 16, 2023 · 0 comments · Fixed by #1071
Closed

Renaming type alias misses alias-as-constructor #972

adamdicarlo0 opened this issue May 16, 2023 · 0 comments · Fixed by #1071
Milestone

Comments

@adamdicarlo0
Copy link

adamdicarlo0 commented May 16, 2023

When renaming a type alias, references to the alias used as a constructor function are not renamed.

Expected Behavior

Given this code:

import Json.Decode as Decode
import Json.Decode.Pipeline as Decode


type alias MyRecord =
    { score : Int
    }


decodeStuff : Decode.Decoder MyRecord
decodeStuff =
    Decode.succeed MyRecord
        |> Decode.required "score" Decode.int

Renaming MyReccorrd on the first line to Score should result in this (imports removed for brevity):

type alias Score =
    { data : Int
    }


decodeStuff : Decode.Decoder Score
decodeStuff =
    Decode.succeed Score
        |> Decode.required "data" Decode.int

but it does not change the reference passed to Decode.succeed.

Current Behavior

The result of renaming the type alias to Score is incorrect:

type alias Score =
    { data : Int
    }


decodeStuff : Decode.Decoder Score
decodeStuff =
    Decode.succeed MyRecord
        |> Decode.required "data" Decode.int

Possible Solution

I haven't looked at the code for this project so I'd just be conjecturing. :)

If given some direction, I could at least try to take a stab at the fix!

Steps to Reproduce (for bugs)

An even more minimal repro:

type alias MyRecord =
    { data : Int
    }


stuff : MyRecord
stuff =
    MyRecord 1

Same problem; renaming the type alias does not change the last line of this snippet.

Context

It's a nuisance, more than anything, but when renaming multiple things at once and forgetting about this issue (say, the reference is in another file) things can get confusingly broken. Especially in the case where I'd realized two types were named "backward" and tried to swap their names.

Your Environment

  • Version used: 2.7.0
  • Editor used: NeoVim 0.9.0, LuaJIT 2.1.0-beta3
  • Environment name and version: Node 18.16.0
  • Operating System and version: Garuda Linux (rolling, Arch-based) -- kernel 6.2.13-zen-1-zen
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

Successfully merging a pull request may close this issue.

2 participants