similar to: Segfault when parsing UTF-8 text with srcrefs

Displaying 18 results from an estimated 18 matches similar to: "Segfault when parsing UTF-8 text with srcrefs"

2011 May 12
1
Recursively parsing srcrefs
Hi all, Is it possible to "recursively" parse srcrefs to match the recursive structure of the underlying code? I'm interested in this because it's the final step in allowing functions to modify other functions while preserving the original source. I've tried to make a bit of demo of what I want to do below, and I think I may uncovered a bug in parse. f <- function(x =
2024 May 28
1
Segfault when parsing UTF-8 text with srcrefs
On 5/28/24 19:35, Hadley Wickham wrote: > Hi all, > > When I run the following code, R segfaults: > > text <- "?" > srcfile <- srcfilecopy("test.r", text) > parse(textConnection(text), srcfile = srcfile) > > It doesn't segfault if text is ASCII, or it's not wrapped in > textConnection, or srcfile isn't set. Thanks, this is
2024 May 30
1
[External] Re: Segfault when parsing UTF-8 text with srcrefs
I get an R error and no segfault: > parse(textConnection(text), srcfile = srcfile) Error in parse(textConnection(text), srcfile = srcfile) : test.r:1:1: unexpected $end 1: ? ^ This is R 4.3.0, so maybe the bug has been introduced since then... Version and system info: > version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system
2012 Jul 05
1
Extracting srcref for S4 methods
Hi, on R version 2.15.1 (2012-06-22) (Platform: i686-pc-linux-gnu (32-bit)) sourced functions have srcref attached as an attribute. Are such data also available for S4 generics and methods? How? (See sample code below) Thank you. Bests, Renaud f <- textConnection( " f <- function(){} setGeneric('myfun', function(x, ...) standardGeneric('myfun'))
2009 Feb 12
1
Why is srcref of length 6 and not 4 ?
Hello, Consider this file (/tmp/test.R) : <file> f <- function( x, y = 2 ){ z <- x + y print( z ) } </file> I get this in R 2.7.2 : > p <- parse( "/tmp/test.R" ) > str( attr( p, "srcref" ) ) List of 1 $ :Class 'srcref' atomic [1:4] 1 1 4 1 .. ..- attr(*, "srcfile")=Class 'srcfile' length 4 <environment>
2011 Nov 19
0
Problems with new srcref warnings in R 2.14 (development)
Dear R developers, Print method for function now tries to open the source file associated with srcref of the function. It outputs only the warning, if file cannot be open, and forgets to print the function definition. Example: eval(parse(text = "tf <- function(a){ b <- a^4 b }", srcfile = srcfile("xxx at 17"))) > tf <srcref: file "xxx at 17"
2013 Dec 13
1
Proper way to drop 'srcref' from an expression created via substitute(function() ...)?
First, why does this expression have a 'srcref' element: > exprA <- substitute(function(x) a*x, list(a=2)) > print(exprA) function(x) 2 * x > str(as.list(exprA)) List of 4 $ : symbol function $ :Dotted pair list of 1 ..$ x: symbol $ : language 2 * x $ :Class 'srcref' atomic [1:8] 1 20 1 34 20 34 1 1 .. ..- attr(*, "srcfile")=Classes
2018 Jun 20
0
incomplete results from as.character.srcref() in some cases involving quote()
wholeSrcref attribute is documented in ?parse to be the source reference corresponding to the already parsed text. The implementation in the parser matches the documentation - the code stops at the last byte/character of the expression, that is, on the closing brace - which is the "already parsed text". I think this works as documented (also source() uses the current implementation
2024 Jan 18
0
Choices to remove `srcref` (and its buddies) when serializing objects
> ------------------------------ > > Date: Wed, 17 Jan 2024 11:35:02 -0500 > > From: Dipterix Wang <dipterix.wang at gmail.com> > > To: Lionel Henry <lionel at posit.co>, Tomas Kalibera > > <tomas.kalibera at gmail.com> > > Cc: r-devel at r-project.org > > Subject: Re: [Rd] Choices to remove `srcref` (and its buddies) when > >
2020 Sep 02
3
sys.call() 's srcref doesn't match the language
Dear R-devel, I found this behavior disturbing, if `1 + f()` is called, `sys.call()` called inside of `f` will return a quoted `f()` with a "srcref" that prints "1 + f()". I don't know which one is good but I don't think they can be correct at the same time. Here's a reproducible example: f <- function(){ sc <- sys.call() print(sc) attr(sc,
2018 Jun 18
2
incomplete results from as.character.srcref() in some cases involving quote()
Hi, The result of as,character() on 'srcref' objects doesn't have the closing ')' in some cases involving 'quote': > e4 <- quote({2+2}) > class(attr(e4, "wholeSrcref")) [1] "srcref" > as.character(attr(e4, "wholeSrcref")) [1] "e4 <- quote({2+2}" As a result printing the object also lacks it and gives an
2024 Jan 18
1
[External] Re: Choices to remove `srcref` (and its buddies) when serializing objects
On Thu, 18 Jan 2024, Ivan Krylov via R-devel wrote: > ? Tue, 16 Jan 2024 14:16:19 -0500 > Dipterix Wang <dipterix.wang at gmail.com> ?????: > >> Could you recommend any packages/functions that compute hash such >> that the source references and sexpinfo_struct are ignored? Basically >> a version of `serialize` that convert R objects to raw without >> storing
2014 Jan 07
1
Why do methods of "initialize" have no "srcref" attribute as other S4 mehtods?
For documentation we use a system that generates Rd files from special comments in the code. (inlinedocs). It is crucial to be able to get the defining source code for objects like methods to extract the comments from it. Here is an R session that shows how this works for several kinds of methods and (at the end of the session) how if fails for methods of "initialize" >
2024 Jan 12
2
Choices to remove `srcref` (and its buddies) when serializing objects
Dear R devs, I was digging into a package issue today when I realized R serialize function not always generate the same results on equivalent objects when users choose to run differently. For example, the following code serialize(with(new.env(), { function(){} }), NULL, TRUE) generates different results when I copy-paste into console vs when I use ctrl+shift+enter to source the file in RStudio.
2024 Jan 17
1
Choices to remove `srcref` (and its buddies) when serializing objects
> I think one could implement hashing on the fly without any > serialization, similarly to how identical works, but I am not aware of > any existing implementation We have one in vctrs but it's not exported: https://github.com/r-lib/vctrs/blob/main/src/hash.c The main use is vectorised hashing: ``` # Non-vectorised vctrs:::obj_hash(1:10) #> [1] 1e 77 ce 48 # Vectorised
2024 Jan 18
1
Choices to remove `srcref` (and its buddies) when serializing objects
? Tue, 16 Jan 2024 14:16:19 -0500 Dipterix Wang <dipterix.wang at gmail.com> ?????: > Could you recommend any packages/functions that compute hash such > that the source references and sexpinfo_struct are ignored? Basically > a version of `serialize` that convert R objects to raw without > storing the ancillary source reference and sexpinfo. I can show how this can be done, but
2024 Jan 17
1
Choices to remove `srcref` (and its buddies) when serializing objects
On 1/16/24 20:16, Dipterix Wang wrote: > Could you recommend any packages/functions that compute hash such that > the source references and sexpinfo_struct are ignored? Basically a > version of `serialize` that convert R objects to raw without storing > the ancillary source reference and sexpinfo. > I think most people would think of `digest` but that package uses >
2024 Jan 16
2
Choices to remove `srcref` (and its buddies) when serializing objects
Could you recommend any packages/functions that compute hash such that the source references and sexpinfo_struct are ignored? Basically a version of `serialize` that convert R objects to raw without storing the ancillary source reference and sexpinfo. I think most people would think of `digest` but that package uses `serialize` (see discussion