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

Cannot launch polymorphic functions via lenses #188

Open
nickbattle opened this issue Oct 15, 2022 · 3 comments
Open

Cannot launch polymorphic functions via lenses #188

nickbattle opened this issue Oct 15, 2022 · 3 comments
Labels
fixed in VDMJ Fixed, but awaiting integration of VDMJ into extension UI bug Something isn't working in the VSCode UI
Milestone

Comments

@nickbattle
Copy link
Collaborator

If you define a polymorphic function, like this:

functions
        Launch | Debug
        set2seq[@T]: set of @T -> seq of @T
        set2seq(a) == ...

You get the Launch | Debug lenses above it as usual, but since the launch selection (at the Client) does not prompt for the @T type parameter, you get an error when the launch is performed:

set2seq({4,3,2,1}) = Cannot evaluate set2seq({4,3,2,1}) : Error 3350: Polymorphic function has not been instantiated in 'Set2Seq' (console) at line 1:1

That is because it is launched as set2seq({4,3,2,1}) rather than set2Seq[nat]({4,3,2,1}).

The Launch and Debug lens commands need to be sensitive to polymorphic functions and prompt for the type parameter(s) as well as the arguments. That probably requires the type names to be sent in the JSON arguments from the lens.

@nickbattle
Copy link
Collaborator Author

The current lens arguments are as follows:

"command": 
{
	"title": "Launch",
	"command": "vdm-vscode.addLensRunConfiguration",
	"arguments": 
	[
		{
			"name": "Launch set2seq",
			"defaultName": "Set2Seq",
			"type": "vdm",
			"request": "launch",
			"noDebug": true,
			"remoteControl": null,
			"applyName": "set2seq",
			"applyArgs": 
			[
				{
					"name": "a",
					"type": "set of (@T)"
				}
			]
		}
	]
}

I suggest we add an (optional) applyTypes section, with just a list of type name strings like @T in this example. The UI would then prompt for these and add them after the function name in the launch.

...
        applyTypes
        [
                {
                        "name": "@T"
                }
        ]
...

@nickbattle
Copy link
Collaborator Author

This is now available in the "development" branch of VDMJ...

{
	"title": "Debug",
	"command": "vdm-vscode.addLensRunConfiguration",
	"arguments": 
	[
		{
			"name": "Debug set2seq",
			"defaultName": "Set2Seq",
			"type": "vdm",
			"request": "launch",
			"noDebug": false,
			"remoteControl": null,
			"applyName": "set2seq",
			"applyTypes": 
			[
				"@T"
			],
			"applyArgs": 
			[
				{
					"name": "a",
					"type": "set of (@T)"
				}
			]
		}
	]
}

@nickbattle nickbattle added UI bug Something isn't working in the VSCode UI fixed in VDMJ Fixed, but awaiting integration of VDMJ into extension labels Oct 15, 2022
@nickbattle
Copy link
Collaborator Author

Obviously this only applies to explicit functions with type parameters. Implicit functions or operations do not have the applyTypes value in the lens argument returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in VDMJ Fixed, but awaiting integration of VDMJ into extension UI bug Something isn't working in the VSCode UI
Projects
None yet
Development

No branches or pull requests

2 participants