Skip to content

Fix SynType.CreateApp throwing "unexpected type: App"#198

Merged
7sharp9 merged 2 commits intomasterfrom
copilot/fix-syntype-createapp-error
Feb 25, 2026
Merged

Fix SynType.CreateApp throwing "unexpected type: App"#198
7sharp9 merged 2 commits intomasterfrom
copilot/fix-syntype-createapp-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 25, 2026

SynType.CreateApp was passing None for lessRange and greaterRange in the SynType.App constructor, causing an System.Exception: unexpected type: App at runtime when isPostfix is false and angle-bracket ranges are expected.

Change

  • AstExtensions.fs: replace None with Some range0 for both lessRange and greaterRange in SynType.CreateApp, consistent with every other SynType.App call in the same file (Option, ResizeArray, Set, Map, List, etc.)
// Before
SynType.App(typ, None, args, dotsOrCommas args, None, (defaultArg isPostfix false), range0)

// After
SynType.App(typ, Some range0, args, dotsOrCommas args, Some range0, (defaultArg isPostfix false), range0)
Original prompt

This section details on the original issue you should resolve

<issue_title>error when using SynType.CreateApp</issue_title>
<issue_description>SynType.CreateApp throws the error System.Exception: unexpected type: App. This seems to be caused by missing lessRange and greaterRange arguments, which I assume are required when isPostfix is false.

https://github.com/MoiraeSoftware/myriad/blob/3c9818faabf9d508c10c28d5ecd26e66fafb48a1/src/Myriad.Core/AstExtensions.fs#L195-L196</issue_description>

Comments on the Issue (you are @copilot in this section)

@7sharp9 Im guessing its just a case of adding a few range0 where they are expected to be present. @7sharp9 Yeah when the AST is updated there's typically something added in so it's just a matter of adding in fake locations for the code start/end elements.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: 7sharp9 <588746+7sharp9@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error when using SynType.CreateApp due to missing arguments Fix SynType.CreateApp throwing "unexpected type: App" Feb 25, 2026
Copy link
Copy Markdown
Collaborator

@7sharp9 7sharp9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean change.

@7sharp9 7sharp9 marked this pull request as ready for review February 25, 2026 20:08
Copilot AI review requested due to automatic review settings February 25, 2026 20:08
@7sharp9 7sharp9 merged commit 45312a0 into master Feb 25, 2026
28 checks passed
@7sharp9 7sharp9 deleted the copilot/fix-syntype-createapp-error branch February 25, 2026 20:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes runtime failures when constructing SynType.App nodes via SynType.CreateApp by providing the required angle-bracket ranges, aligning with the rest of AstExtensionsSynType.App helpers.

Changes:

  • Update SynType.CreateApp to pass Some range0 for both lessRange and greaterRange when building SynType.App.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

type SynType with
static member CreateApp (typ, args, ?isPostfix) =
SynType.App(typ, None, args, dotsOrCommas args, None, (defaultArg isPostfix false), range0)
SynType.App(typ, Some range0, args, dotsOrCommas args, Some range0, (defaultArg isPostfix false), range0)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SynType.App invocation is still using positional arguments, while every other SynType.App call in this file uses named arguments (typeName=, lessRange=, greaterRange=, etc.). Consider switching this helper to named arguments as well to make the parameter intent explicit and reduce the chance of future FCS signature changes silently breaking the call again.

Suggested change
SynType.App(typ, Some range0, args, dotsOrCommas args, Some range0, (defaultArg isPostfix false), range0)
SynType.App(
typeName = typ,
lessRange = Some range0,
typeArgs = args,
commaRanges = dotsOrCommas args,
greaterRange = Some range0,
isPostfix = defaultArg isPostfix false,
range = range0
)

Copilot uses AI. Check for mistakes.
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 this pull request may close these issues.

error when using SynType.CreateApp

3 participants