Skip to content

Commit

Permalink
fix the builtin throws
Browse files Browse the repository at this point in the history
  • Loading branch information
peze authored and yndu13 committed Aug 1, 2024
1 parent 5f9cce9 commit b18af68
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
2 changes: 0 additions & 2 deletions builtin/date.dara
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ function dayOfWeek(): integer;

function weekOfYear(): integer;

function weekOfMonth(): integer;

function month(): integer;

function year(): integer;
4 changes: 2 additions & 2 deletions builtin/file.dara
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async function write(data: bytes): void;

async function close(): void;

static function createReadStream(path: string): readable;
static function createReadStream(path: string) throws: readable;

static function createWriteStream(path: string): writable;
static function createWriteStream(path: string) throws: writable;

static async function exists(path: string): boolean;
14 changes: 7 additions & 7 deletions builtin/stream.dara
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
init(){}

function read(size: number): bytes;
function read(size: number) throws: bytes;

function write(data: bytes): void;
function write(data: bytes) throws: void;

function pipe(rs: writable): void;
function pipe(rs: writable) throws: void;

/**
* Read data from a readable stream, and compose it to a bytes
* @param stream the readable stream
* @return the bytes result
*/
static async function readAsBytes(stream: readable): bytes;
static async function readAsBytes(stream: readable) throws: bytes;

/**
* Read data from a readable stream, and parse it by JSON format
* @param stream the readable stream
* @return the parsed result
*/
static async function readAsJSON(stream: readable): any ;
static async function readAsJSON(stream: readable) throws: any ;

/**
* Read data from a readable stream, and compose it to a string
* @param stream the readable stream
* @return the string result
*/
static async function readAsString(stream: readable): string;
static async function readAsString(stream: readable) throws: string;

static async function readAsSSE(stream: readable): asyncIterator[$SSEEvent];
static async function readAsSSE(stream: readable) throws: asyncIterator[$SSEEvent];
2 changes: 1 addition & 1 deletion builtin/string.dara
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ init(data: string){}

function split(sep: string): [ string ];

function replace(regexStr: string, newStr: string): string;
function replace(regexStr: string, newStr: string)throws : string;

function contains(substr: string): boolean;

Expand Down
2 changes: 1 addition & 1 deletion builtin/url.dara
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function href(): string;

function auth(): string;

static function parse(url: string): $URL;
static function parse(url: string) throws: $URL;

static function urlEncode(url: string): string;

Expand Down
3 changes: 2 additions & 1 deletion lib/semantic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2309,8 +2309,9 @@ class TypeChecker {
} else if(type.type === 'model') {
moduleName = '$ModelInstance';
ast.builtinModule = moduleName;
} else if(builtin.has(moduleName)) {
ast.builtinModule = moduleName;
}

}

const checker = this.getChecker(moduleName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"builtin",
"index.js"
],
"repository": "git@github.com:peze/darabonba.git"
"repository": "git@github.com:aliyun/darabonba.git"
}
1 change: 0 additions & 1 deletion test/fixtures/builtin_module/date.dara
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ static async function main(args: [string]): void {
var second = date.second();
var dayOfMonth = date.dayOfMonth();
var dayOfWeek = date.dayOfWeek();
var weekOfMonth = date.weekOfMonth();
var weekOfYear = date.weekOfYear();
var month = date.month();
var year = date.year();
Expand Down

0 comments on commit b18af68

Please sign in to comment.