question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should not evaluate delayed-assign object before it gets called

See original GitHub issue

Describe the bug

VSCode-R evaluates the delayed-assign object too early.

To Reproduce

  1. Open VSCode (with VSCode-R installed)
  2. Open the radian terminal in VSCode
  3. Paste the following code in to the radian terminal
delayedAssign("delayed_obj", {
  stop("should not execute")
})

in VSCode’s terminal

The code inside has been executed but it shouldn’t as delayed_obj is not evaluated

image

in a normal terminal

The code inside is executed only when delayed_obj gets evaluated

image

Do you want to fix by self? (I hope your help!)

Yes

(If yes,) what kind of help do you want? (e.g. Which file should I fix, Survey (related documents)

I want to know where to get started…

(If related)setting.json

{
    "remote.SSH.connectTimeout": 30,
    "remote.SSH.maxReconnectionAttempts": 5,
    "remote.SSH.remotePlatform": {
        "10.4.119.58": "linux",
        "10.4.120.45": "linux"
    },
    "r.sessionWatcher": true,
    "r.rterm.windows": "D:\\app\\Python\\Python39\\Scripts\\radian.exe",
    "r.rpath.windows": "D:\\app\\R-4.0.0\\bin\\R.exe",
    "diffEditor.renderSideBySide": true,
    "[r]": {
        "editor.formatOnSave": false
    },
    "git.autofetchPeriod": 300,
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "window.zoomLevel": 0,
    "r.lsp.diagnostics": false,
    "git.confirmSync": false,
    "r.alwaysUseActiveTerminal": true,
    "r.bracketedPaste": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "git.autofetch": true,
    "editor.tabSize": 2,
    "terminal.external.windowsExec": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "typescript.suggest.paths": false
}

Expected behavior

Should not evaluate the delayed-assign object so early - we should only evaluate the object when we really need it

Screenshots

See the comment in Reproduce Step

Environment (please complete the following information):

  • OS: Win 10
  • VSCode Version: 1.52.1
  • R Version: 4.0.2
  • vscode-R version: 1.6.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
renkun-kencommented, Jan 6, 2021

I think the easiest way is to use rlang::env_binding_are_lazy(.GlobalEnv).

1reaction
tdeenescommented, Jan 6, 2021

I’m hesitated to introduce an R package to work with session watcher like vscDebugger does with VSCode-R-Debugger because it makes vscode-R less work-out-of-the-box unless we also make the whole installation process fast and smooth.

Well, the relevant code already depends on jsonlite. So adding a further tiny package should not make the installation process much harder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

delayedAssign: Delay Evaluation - Rdrr.io
The expression assigned to a promise by delayedAssign will not be evaluated until it is eventually 'forced'. This happens when the variable is...
Read more >
Lazy evaluation in R – is assign affected? - Stack Overflow
delayedAssign is a low-level function, visible to R users/programmers, but it really is only used for lazy loading of packages and should not...
Read more >
What is a Function? · R and C++ - Kevin Ushey
This demonstrates R s lazy evaluation of function arguments. When R binds formals to the local generated function environments, it does so with ......
Read more >
Should not evaluate delayed-assign object before it gets called
VSCode-R evaluates the delayed-assign object too early. To Reproduce. Open VSCode (with VSCode-R installed); Open the radian terminal in VSCode; Paste the ...
Read more >
[Rd] Substitute / delayedAssign (was: Substitute unaware when ...
After conversion, each expression in the list will be automatically evaluated when the variable with the same name is accessed in the environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found